The Complete Production SOP: How to Deploy and Run ESLint Security Rules & AST Taint Hardening in Autonomous AI Agents
Step-by-step SOP to install and run ESLint Security Rules & AST Taint Hardening in Codex, Claude Code, and Cursor. Prevent prototype pollution & ReDoS.
Technical Overview & Architectural Context
Autonomous coding agents frequently generate brittle boilerplate when refactoring JavaScript and TypeScript codebases. When tasked with performance optimizations or parsing logic, models often produce naive object deep-merge functions, construct dynamic regexes without bounds checking, or fall back to eval-like constructs. Without deterministic static analysis guardrails, agents routinely introduce prototype pollution vulnerabilities (__proto__ injection), ReDoS (Regular Expression Denial of Service) through catastrophic backtracking quantifiers, and unchecked AST sink mutations. The ESLint Security Rules & AST Taint Hardening skill (eslint-security-rules-hardening) embeds strict procedural standards into Codex, Claude Code, Cursor, and Windsurf workflows. By enforcing plugin:security/recommended, typescript-eslint AST boundary checks, and explicit Object.hasOwn() safeguards, this skill forces the agent to validate all dynamic property access patterns, audit regular expressions before compilation, and self-correct invalid configurations prior to user delivery.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Create the local skill manifest directory and inject verified procedural rules into the agent context root.
Autonomous runtimes like Claude Code, Cursor, and Codex automatically parse local skill registries located under .agents/skills or ~/.agents/skills. Placing the SKILL.md definition directly within the repository root under .agents/skills/eslint-security-rules-hardening ensures the agent dynamically inspects AST security triggers whenever ESLint or vulnerability mitigation tasks are assigned.
mkdir -p .agents/skills/eslint-security-rules-hardening && cat <<'EOF' > .agents/skills/eslint-security-rules-hardening/SKILL.md
---
name: "eslint-security-rules-hardening"
description: "Harden JavaScript and TypeScript codebases against prototype pollution and injection."
metadata:
author: "Node Security"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "configure eslint-plugin-security"
- "prevent prototype pollution eslint"
- "detect redos regex eslint"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---
# ESLint Security Rules & AST Taint Hardening
Configures eslint-plugin-security and typescript-eslint: detecting eval(), prototype pollution, unsafe regular expressions (ReDoS), child_process execution, and DOM XSS sinks.
## When to Invoke
Invoke this skill whenever you need to:
- configure eslint-plugin-security
- prevent prototype pollution eslint
- detect redos regex eslint
## Execution SOP & Rules
1. Add plugin:security/recommended to the extends array in ESLint configuration.
2. Prevent prototype pollution by validating object keys against Object.hasOwn() before assignment.
3. Audit regular expressions for nested quantifiers ((a+)+) that cause ReDoS CPU spikes.
4. Forbid dynamic code execution via eval() or new Function().
## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
EOFimport securityPlugin from 'eslint-plugin-security';
import tseslint from 'typescript-eslint';
export default tseslint.config(
tseslint.configs.recommended,
securityPlugin.configs.recommended,
{
rules: {
'security/detect-object-injection': 'warn',
'security/detect-unsafe-regex': 'error',
'security/detect-non-literal-fs-filename': 'warn',
'security/detect-eval-with-expression': 'error'
}
}
);Mounting the skill locally within the repository's .agents directory keeps your prompt context lean; the agent loads AST rules on-demand rather than consuming prompt tokens during every standard interaction.
Ensure fs_write permissions are scoped to 'workspace'. Do not allow agents to write outside repo bounds when generating ESLint config files.
Security Plugin & Parser Dependency Installation
Install eslint-plugin-security and typescript-eslint tooling to support modern Flat Config and AST analysis.
Modern ESLint v9 utilizes the Flat Config format. To ensure the agent can execute lint checks and detect AST taint without syntax failures, both eslint-plugin-security and typescript-eslint must be installed as devDependencies.
npm install --save-dev eslint-plugin-security @eslint/js typescript-eslintFreeze lockfiles using npm ci or pnpm install --frozen-lockfile in CI/CD pipelines to prevent subtle AST rule shifts.
Certain legacy packages depend on eslint-plugin-security v1.4 which fails under ESLint 9 Flat Config; ensure eslint-plugin-security >= 3.0.0 is used.
Intent Matching & Trigger Invocation
Trigger the autonomous skill using precise AST taint and security keywords.
Runtimes match user intent against triggers specified in SKILL.md. By commanding the agent with explicit trigger phrasing, such as 'configure eslint-plugin-security' or 'prevent prototype pollution eslint', the agent automatically selects the security SOP and applies AST rules to target directories.
# Run within agent prompt interface:
claude-code "configure eslint-plugin-security and prevent prototype pollution eslint in src/utils/merger.ts"Combine action-oriented verbs ('audit', 'harden', 'prevent') with the exact SKILL.md triggers to guarantee immediate execution without conversational back-and-forth.
Avoid ambiguous phrasing like 'make my JS code safer' which can trigger generic hallucinated linter suggestions instead of the registered skill.
Verification, AST Linting & Quality Gate
Execute automated self-healing checks to confirm security violations are resolved.
Instruct the agent to run the configured security linter and parse the resulting diagnostics. If security/detect-object-injection or security/detect-unsafe-regex errors occur, the agent must inspect the AST node, apply defensive coding (e.g., Object.hasOwn check or safe regex replacement), and rerun linting until exit code 0 is attained.
npx eslint src/ --max-warnings=0 && npm testConfigure the agent to inspect git diff after the lint pass to verify that security fixes did not alter functional behavior or breaking API contracts.
Disabling security rules with inline // eslint-disable-next-line comments should be strictly forbidden in the agent's system prompt instructions.
Real-World Scenario: Harden Deep Object Merge Against Prototype Pollution & Catastrophic Regex Backtracking
“We have an insecure deepMerge utility in src/merge.js that takes untrusted user input. Please configure eslint-plugin-security, audit the file, prevent prototype pollution eslint vulnerabilities, and detect redos regex eslint risks.”
Runtime Troubleshooting & Failure Modes
Root Cause: Incompatible CommonJS/ESM interop when loading eslint-plugin-security inside ESLint v9 Flat Config format.
import securityPlugin from 'eslint-plugin-security';
// Use securityPlugin.configs.recommended directly in export default array.Root Cause: The rule flags all dynamic bracket accessors as potential injection vectors even when access is bounded.
if (Object.hasOwn(dictionary, key) && !['__proto__', 'constructor', 'prototype'].includes(key)) { const value = dictionary[key]; }Frequently Asked Questions (ESLint Security Rules & AST Taint Hardening SOP)
Q:Can I use ESLint Security Rules & AST Taint Hardening across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification supported across all modern agent runtimes. Simply place the manifest in your global ~/.agents/skills or project-local .agents/skills directory.
Q:How does ESLint Security Rules & AST Taint Hardening prevent context window overflow during long agent sessions?
By establishing concise procedural boundaries and deterministic validation gates, the skill avoids injecting massive linter dictionaries into context. Instead, it instructs the agent to run local CLI lint checks and only process stdout/stderr diagnostics on failure.
Q:Does this skill require escalated root or container permissions?
No. It is audited with a security score of 98/100 and runs safely within workspace-scoped sandboxes with net_access set to false and fs_write restricted to the workspace boundary.
Ready to equip your autonomous agent with ESLint Security Rules & AST Taint Hardening?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.