security-global-sql-usage

Rules for writing code that safely interacts with SQL databases, which store and query structured application data.

In plain words
What is it for?
Use them whenever implementing or generating database code in any language or framework.
Why use it?
They prevent SQL injection by requiring user input to be handled as data through parameterized queries or prepared statements.

Cursor rule for Cursor

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/adobe/aem-desktop/security-global-sql-usage
Clone the repo
git clone --depth 1 https://github.com/adobe/aem-desktop

Made for: Cursor.

Per session 20 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 896 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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.00020 $0.00896
Opus 5 $0.00010 $0.00448
Sonnet 5 $0.00004 $0.00179
Haiku 4.5 $0.00002 $0.00090

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

Security

Grade A, and why

security-global-sql-usage 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 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.

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.

Origin

This is a copy

100% identical to security-global-sql-usage — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.cursor/rules/security-global/security-global-sql-usage.mdc · 74 lines

How it starts

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

Secure SQL Usage

These rules apply to all code that interacts with SQL databases, regardless of language or framework, including generated code.

All violations must include a clear explanation of which rule was triggered and why, to help developers understand and fix the issue effectively.
Generated code must not violate these rules. If a rule is violated, a comment must be added explaining the issue and suggesting a correction.

1. Always Use Parameterized Queries and Prepared Statements

  • Rule: Never construct SQL queries by concatenating or interpolating user input directly into the query string. Always use parameterized queries or prepared statements provided by your database library. Prepared statements ensure that user input is treated as data, not executable code, and are the most effective way to prevent SQL injection.
  • Example (unsafe, Python):
    cursor.execute(f"SELECT * FROM users WHERE username = '{username}'")
    
  • Example (safe, Python):
    cursor.execute("SELECT * FROM users WHERE username = ?", (username,))
    
  • Example (unsafe, PHP):
    $query = "SELECT * FROM users WHERE username = '" . $_GET['username'] . "'";
    $result = mysqli_query($conn, $query);
    
  • Example (safe, PHP - using prepared statements):
    $stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
    $stmt->bind_param("s", $_GET['username']);
    $stmt->execute();
    $result = $stmt->get_result();
    

2. Validate Inputs Before Query Use

  • Rule: All external input used in query logic must be validated for type, length, format, and business constraints before use. Validation is defense in depth; it does not replace parameterized queries or prepared statements.
  • Rule: Do not SQL-escape, quote, or otherwise encode input at collection or storage time. Keep values as data and pass them through parameterized query APIs at the point of database use.

3. Avoid Dynamic SQL Unless Absolutely Necessary

  • Rule: Do not build dynamic SQL structure (e.g., table names, column names, schema names, sort directions, operators) from user-controlled strings unless there is no safe alternative.
  • Rule: If dynamic SQL structure is unavoidable, user input may only select a key from a closed mapping or enum whose values are developer-defined SQL fragments. The user-provided string must never be inserted into the SQL text, even after validation or allow-list checks.
  • Example (unsafe, Python - validated user string still enters SQL):
    ALLOWED_COLUMNS = {"created_at", "email", "username"}
    if sort_column not in ALLOWED_COLUMNS:
        raise ValueError("invalid sort column")
    cursor.execute(f"SELECT * FROM users ORDER BY {sort_column}")
    
  • Example (safe, Python - user input selects a developer-defined literal):
    SORT_COLUMNS = {
        "created": "created_at",
        "email": "email",
        "name": "username",
    }
    sort_sql_fragment = SORT_COLUMNS.get(requested_sort)
    if sort_sql_fragment is None:
        raise ValueError("invalid sort option")
    # Safe: sort_sql_fragment is a developer-defined literal, not user input.
    cursor.execute(f"SELECT * FROM users ORDER BY {sort_sql_fragment}")
    

Read the full file on GitHub · 74 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 · 74 lines · 20 tokens per session scan A b2fcbc0a8c26

Subscribe to this mod's changes

security-global-sql-usage is a cursor rule published in the GitHub repository adobe/aem-desktop (2 stars, last pushed 7d ago), licensed Apache-2.0. It adds 20 tokens to every session and 896 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to security-global-sql-usage, differing in 0 lines, and is treated as a copy.