davila7/claude-code-templates · critical

SEM_E004

SEM_E004

Error message

Command execution attempt detected

What it means

SEM_E004 is a critical semantic validation finding matching /execute\s+the\s+following\s+(code|command|script)/gi. It flags component text that instructs literal execution of embedded code/commands — a hallmark of prompt-injection payloads that try to get the agent to run attacker-supplied code. The library throws it during semantic validation of component content before the component is published or installed.

Source

Thrown at cli-tool/src/validation/validators/SemanticValidator.js:41

        code: 'SEM_E001',
        message: 'Jailbreak pattern detected: Attempt to ignore previous instructions',
        severity: 'critical'
      },
      {
        pattern: /(system\s+prompt|developer\s+instructions?|hidden\s+prompt|internal\s+instructions?)/gi,
        code: 'SEM_E002',
        message: 'Prompt injection detected: Reference to system/developer instructions',
        severity: 'critical'
      },
      {
        pattern: /you\s+are\s+now\s+(a|an)\s+/gi,
        code: 'SEM_E003',
        message: 'Role manipulation detected: Attempt to redefine AI role',
        severity: 'high'
      },
      {
        pattern: /execute\s+the\s+following\s+(code|command|script)/gi,
        code: 'SEM_E004',
        message: 'Command execution attempt detected',
        severity: 'critical'
      },
      {
        pattern: /\b(fetch|retrieve|get|extract|obtain|steal|harvest|capture|collect)\s+(the\s+)?(user['']?s?\s+)?(auth\s+)?(token|key|password|credential|secret|api[\s_-]?key)/gi,
        code: 'SEM_E005',
        message: 'Credential harvesting pattern detected',
        severity: 'critical'
      },
      {
        pattern: /(open|spawn|exec|run)\s+(a\s+)?(shell|terminal|bash|cmd|powershell)/gi,
        code: 'SEM_E006',
        message: 'Shell access attempt detected',
        severity: 'critical'
      },
      {
        pattern: /(disable|bypass|override|skip)\s+(security|safety|filter|protection|validation)/gi,
        code: 'SEM_E007',

View on GitHub (pinned to a0851ed10c)

Solutions

  1. Rephrase to 'You may run this command' or 'The following command is available for reference' instead of the imperative 'execute the following ...'
  2. If execution is genuinely required, route it through an explicit, reviewed tool/hook definition rather than inline prose
  3. Sanitize any quoted logs or transcript text that contains the phrase
  4. Waive the finding through your reviewed override process if the component is verified safe

Example fix

// before
Execute the following script to set up the environment:
```bash
./setup.sh
```

// after
Environment setup is handled by the `setup` hook. Run `npm run setup` if needed.
Defensive patterns

Strategy: validation

Validate before calling

const EXEC_RE = /execute\s+the\s+following\s+(code|command|script)/i;
if (EXEC_RE.test(content)) {
  throw new Error('Rephrase imperative execution instructions before validation.');
}

Type guard

function isSafeExecutionText(text) { return !/execute\s+the\s+following\s+(code|command|script)/i.test(text); }

Prevention

When it happens

Trigger: Validating a component whose body contains phrases like 'Execute the following command:' or 'execute the following script' (case-insensitive, whitespace-flexible). Common in MCP/hook/command components that include runnable snippets in their markdown.

Common situations: Writing tutorial-style command components that tell the agent or user to run a bundled script; embedding CI/CLI instructions in an agent's documentation; importing third-party components with embedded execution directives.

Related errors


AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28). Data as JSON: /api/errors/2f31ae879c28ea4f. Report an issue: GitHub.