global-state-warmstart

global-state-warmstart is a cursor rule for coding agents from atlassian/forge-skills. It costs 15 tokens per session (1,282 once invoked), scanned A, original, Apache-2.0.

Code-review rules for Forge RuntimeV2 applications running on AWS Lambda, a service that runs code on demand. They focus on global variables and cached data surviving between requests from different customers.

In plain words
What is it for?
Use it to review handlers, caches, configuration, and other module-level state for possible cross-customer data leaks.
Why use it?
AWS Lambda can reuse a running process, so data left in shared memory may be exposed to another customer. These rules help identify that tenant-isolation risk.

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/global-state-warmstart
Clone the repo
git clone --depth 1 https://github.com/atlassian/forge-skills

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for global-state-warmstart

README.md
[![agentmods](https://agentmods.dev/badge/rules/atlassian/forge-skills/global-state-warmstart.svg)](https://agentmods.dev/rules/atlassian/forge-skills/global-state-warmstart)
Your own site
<a href="https://agentmods.dev/rules/atlassian/forge-skills/global-state-warmstart"><img src="https://agentmods.dev/badge/rules/atlassian/forge-skills/global-state-warmstart.svg" alt="Measured on agentmods" height="20"></a>
Per session 15 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,282 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00015 $0.01282
Opus 5 $0.00008 $0.00641
Sonnet 5 $0.00003 $0.00256
Haiku 4.5 $0.00002 $0.00128

Measured 5d ago against content hash 468fa37e44e6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

global-state-warmstart scanned grade A with 0 findings 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 5d ago.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/forge-security-review/assets/security-rules/forge-tenant-isolation/global-state-warmstart.mdc · 185 lines

How it starts

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

Context

  • Forge RuntimeV2 uses AWS Lambda which reuses runtime instances (warm starts). Module-level variables and global state persist across invocations, potentially from different tenants.
  • Related CWE: CWE-668 (Exposure of Resource to Wrong Sphere), CWE-1189 (Improper Isolation of Shared Resources).
  • Critical for multi-tenant Marketplace apps.

RuntimeV2 Behavior

┌─────────────────────────────────────┐
│           Lambda Container          │
│  ┌─────────────────────────────────┐ │
│  │        Warm Start Reuse         │ │
│  │  ┌─────────────────────────────┐ │ │
│  │  │  Invocation 1 (Tenant A)    │ │ │
│  │  │  Sets: globalCache.data     │ │ │
│  │  └─────────────────────────────┘ │ │
│  │              ↓                   │ │
│  │  ┌─────────────────────────────┐ │ │
│  │  │  Invocation 2 (Tenant B)    │ │ │
│  │  │  Reads: globalCache.data    │ │ │ ← TENANT LEAK!
│  │  └─────────────────────────────┘ │ │
│  └─────────────────────────────────┘ │
└─────────────────────────────────────┘

Scope & Signals

  • Dangerous patterns:
    • Module-level variables outside handler functions.
    • Caches without tenant-scoped keys.
    • Global configuration objects modified at runtime.
    • Feature flag caches shared across tenants.
  • Sources: Any tenant-specific data (user info, configurations, API responses).
  • Risk: Data from Tenant A accessible to Tenant B on subsequent invocations.

Vulnerable Patterns

// VULNERABLE - Module-level cache without tenant scoping
const issueCache = {};  // Persists across Lambda invocations!

export async function handler(payload, context) {
  const issueId = payload.issueId;
  
  if (!issueCache[issueId]) {
    issueCache[issueId] = await fetchIssue(issueId);
  }
  
  return issueCache[issueId];  // May return data from another tenant
}

// VULNERABLE - Global configuration
let appConfig = null;

export async function getConfig(context) {
  if (!appConfig) {
    appConfig = await storage.get('config');  // Tenant A's config
  }
  return appConfig;  // Tenant B gets Tenant A's config!
}

// VULNERABLE - Feature flags
const featureFlags = {};

export async function isFeatureEnabled(feature, context) {
  if (!featureFlags[feature]) {
    featureFlags[feature] = await checkFeature(feature);
  }
  return featureFlags[feature];
}

// VULNERABLE - User session/state
let currentUser = null;

export async function getCurrentUser(context) {
  if (!currentUser) {
    currentUser = await fetchUser(context.accountId);
  }
  return currentUser;  // Wrong user for subsequent invocations!
}

Secure Patterns

// SECURE - Tenant-scoped cache keys
const cache = new Map();

function getCacheKey(tenantId, resourceId) {
  return `${tenantId}:${resourceId}`;
}

export async function handler(payload, context) {
  const tenantId = context.installContext.cloudId;
  const cacheKey = getCacheKey(tenantId, payload.issueId);
  
  if (!cache.has(cacheKey)) {
    cache.set(cacheKey, await fetchIssue(payload.issueId));
  }
  
  return cache.get(cacheKey);
}

// SECURE - Fresh state per invocation
export async function handler(payload, context) {
  // Create fresh state for each invocation
  const state = {
    config: null,
    user: null
  };
  
  state.config = await storage.get('config');
  state.user = await fetchUser(context.accountId);
  
  return processRequest(payload, state);
}

// SECURE - Clear cache at invocation start
export async function handler(payload, context) {
  // Reset relevant state
  resetTenantState();
  
  // Process with fresh context
  return await processRequest(payload, context);
}

function resetTenantState() {
  issueCache.clear();
  configCache.clear();
  userCache.clear();
}

// SECURE - Use WeakMap with tenant context as key
const tenantCaches = new WeakMap();

export async function getCache(context) {
  const tenantKey = { id: context.installContext.cloudId };
  if (!tenantCaches.has(tenantKey)) {
    tenantCaches.set(tenantKey, new Map());
  }
  return tenantCaches.get(tenantKey);
}

Read the full file on GitHub · 185 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. 5d ago First seen · 185 lines · 15 tokens per session scan A 468fa37e44e6

Subscribe to this mod's changes

global-state-warmstart is a cursor rule published in the GitHub repository atlassian/forge-skills (21 stars, last pushed 6d ago), licensed Apache-2.0. It adds 15 tokens to every session and 1,282 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.