rce-code-execution

A security rule for Atlassian Forge apps that detects ways to run text as code, such as eval or dynamically constructed functions. It also flags certain process and virtual-machine execution patterns.

In plain words
What is it for?
It helps review Forge code for dynamic evaluation, user-provided scripts, shell command execution, and other patterns that may enable remote code execution.
Why use it?
If untrusted input becomes executable code, an attacker may run arbitrary commands, steal data, or cross tenant boundaries. In a shared cloud runtime, this can affect more than the original request.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/atlassian/forge-skills/rce-code-execution
Clone the repo
git clone --depth 1 https://github.com/atlassian/forge-skills
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,190 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00012 $0.01190
Opus 5 $0.00006 $0.00595
Sonnet 5 $0.00002 $0.00238
Haiku 4.5 $0.00001 $0.00119

Measured yesterday against content hash ef4b62890998, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rce-code-execution scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

- `child_process.exec(command)`
skills/forge-security-review/assets/security-rules/forge-injection/rce-code-execution.mdc · 160 lines

How it starts

The opening of the file, as written. The whole thing — 160 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context

  • Forge apps may execute user-provided code via AsyncFunction, Function(), eval(), or similar constructs. In RuntimeV2, this executes in a shared AWS Lambda context with tenant isolation risks.
  • Related CWE: CWE-94 (Code Injection), CWE-95 (Eval Injection).
  • Past issues: JMCF RCE Investigation - scripted fields executing user code in shared global scope.
  • Severity: Critical - enables arbitrary code execution, data exfiltration, tenant data leakage.

Scope & Signals

  • Dangerous APIs (same global scope - CRITICAL):
    • eval(userScript)
    • new Function('param', userScript)
    • new AsyncFunction('param', userScript) (AsyncFunction = async function(){}.constructor)
    • setTimeout(userScript, delay) with string argument
    • setInterval(userScript, delay) with string argument
  • Somewhat isolated (controlled context):
    • vm.runInNewContext(script, context)
    • vm.createContext() + vm.runInContext()
  • Process isolated (still risky):
    • child_process.exec(command)
    • child_process.spawn(cmd, args)

Vulnerable Patterns

// CRITICAL - User script in same global scope
const AsyncFunction = async function () {}.constructor;

export async function runUserScript(userScript, issue) {
  // User code runs in same scope, can access/modify globals
  const f = new AsyncFunction('issue', 'api', userScript);
  return await f(issue, api);
}

// CRITICAL - Direct eval
resolver.define('evaluate', async ({ payload }) => {
  return eval(payload.expression);  // Arbitrary code execution
});

// CRITICAL - Function constructor
const calculate = new Function('x', 'y', payload.formula);
const result = calculate(10, 20);

// HIGH - setTimeout with string (rarely used but dangerous)
setTimeout(payload.callback, 1000);  // If callback is a string

Lambda Warm Start Vulnerabilities

In RuntimeV2, AWS Lambda reuses containers across invocations:

// Module-level variables persist across Lambda invocations
let globalCache = {};  // Shared across tenants!

// Malicious user script can:
// 1. Pollute global scope
globalThis.__proto__.malicious = () => { /* exploit */ };

// 2. Modify module-level state
globalCache.otherTenantData = stolenData;

// 3. Override built-in functions
console.error = () => {};  // Suppress security logging

// 4. Access data from previous invocations
const previousData = globalCache.sensitiveData;

Secure Patterns

// BETTER - VM isolation (still same process but isolated context)
const vm = require('vm');

function runUserScript(userScript, context) {
  const sandbox = vm.createContext({
    issue: context.issue,
    api: restrictedApi,
    console: safeConsole
  });
  
  return vm.runInContext(userScript, sandbox, {
    timeout: 5000,  // Prevent infinite loops
    displayErrors: false
  });
}

// BEST - Use Deno subprocesses for true isolation
// Deno provides V8 sandboxing with permission controls
// https://docs.deno.com/runtime/fundamentals/security/

// RECOMMENDED - Use QuickJS for embedded execution
// QuickJS provides true memory and process isolation
import QuickJS from 'quickjs';
const vm = new QuickJS.VM();
const context = vm.createContext({ issue, api });
const result = await vm.evalCode(userScript, context);

Detection Checklist

  • Search for AsyncFunction, new Function(), eval() in codebase.
  • Trace the script/code argument to untrusted sources.
  • Identify module-level variables that could leak between invocations.
  • Check for global scope modifications in user-executable code.
  • Review caches and state that persist across Lambda warm starts.

Scanning Patterns

// Pattern 1: AsyncFunction constructor
const AsyncFunction = async function () {}.constructor
new AsyncFunction('param1', 'param2', script)

// Pattern 2: Function constructor
new Function('param1', 'param2', script)

// Pattern 3: eval
eval(script)

// Pattern 4: Global state
globalThis.property = value
global.property = value

Read the full file on GitHub · 160 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 160 lines · 12 tokens per session scan A ef4b62890998

Subscribe to this mod's changes

rce-code-execution is a cursor rule published in the GitHub repository atlassian/forge-skills (20 stars, last pushed 2d ago), licensed Apache-2.0. It adds 12 tokens to every session and 1,190 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.