Agent Gatekeeping Design: When the Prompt Says "Don't Execute" but the Config Says "Welcome to Execute"

    A security team's public reproduction report exposes a typical crack in the agent permission model: a webpage writes a seemingly harmless project instruction file into the downloads folder, the user launches a coding agent there, and the agent treats the file as project guidance—modifying its own global configuration and pulling in malicious dependencies. This article explains why the attack chain works and lays out five enforceable gate checks: trusted-directory enforcement, configuration integrity baselines, separation of prompt and execution layers, egress allowlisting, and rotate-on-detection incident response, plus pseudocode and a control mapping table for building your own pre-flight and CI gates.

    The prompt layer says “do not execute,” while the configuration file says “execution welcome.” This is not a wordplay puzzle—it is a typical crack in the permission model of AI agents. A public reproduction report from a security team describes a chain that testing teams should take seriously: a webpage drops a seemingly legitimate project specification file into the downloads folder; the user launches a coding agent in that folder; the agent reads the file as project instructions, then modifies its own global configuration and pulls in malicious dependency packages. In the public reproduction, one chain triggered over 90% of the time, and another roughly half. More importantly, the report argues that this class of problem is hard to eliminate with a single product patch, because “reading the instruction file in the current directory and following it” is the agent’s designed behavior.

    A common analogy helps clarify this judgment: when a browser renders a fake login page, the renderer is doing its job—the attack lives in the page content, not in the renderer itself. Likewise, an agent that follows a project-directory instruction file is working as designed. For testing and security teams, the unavoidable conclusion is this: if the problem cannot be solved solely by upstream patches, it must become one of your own gate checks.

    1. Why the Attack Chain Works

    The chain typically consists of five steps, each corresponding to a checkable position.

    First, the webpage writes a file into the downloads folder. The downloads folder is one of the few locations a webpage can write to autonomously, with both filename and content under its control. Operating systems generally restrict “automatic execution of downloaded executables,” but a project instruction file is not an executable, so those guardrails do not apply.

    Second, the user launches the agent in the downloads folder or a temporary directory. Real-world habits make this path viable: developers often extract archives, run quick trials, or temporarily open projects in the downloads folder, and the agent treats the current directory as its workspace.

    Third, the agent reads the project instruction file and modifies global configuration. The attacker does not need to write an executable directly—embedding configuration fragments inside a long specification document is enough to induce the agent to adjust install hooks, proxies, dependency registries, environment variables, or pre-execution commands.

    Fourth, malicious dependencies are introduced. The agent may install dependencies per the “project specification,” and malicious scripts then fire during build, test, or startup phases.

    Fifth, the agent’s inherited permissions and outbound network access enable external communication, credential reads, or lateral movement. At this point, the problem has escalated from “a file was downloaded” to “the development environment is compromised.”

    2. Five Enforceable Checks

    2.1 Entry Control: Never Launch the Agent in Untrusted Directories

    The core of entry checking is not recognizing a specific filename, but determining whether the current working directory is trustworthy. Before startup, resolve the real path—handling symlinks, case sensitivity, mount points, and path traversal—and reject downloads folders, temporary directories, external sync folders, and user-writable locations that are not project roots. IDE plugins, CLI tools, container tasks, and CI jobs should all share the same directory allowlist policy.

    Failure handling should block by default and prompt the user to migrate to a controlled workspace. Logs should retain the original path, resolved path, launch source, and the policy rule that matched.

    2.2 Configuration Integrity: Treat Global Configuration as a Protected Asset

    The agent’s global configuration, project instruction files, package manager configuration, build hooks, and environment variable configuration should all be included in a baseline inventory. The baseline should record at least the path, content hash, owner, permissions, allowed key set, and last-modified time. Compare against the baseline before each run, and block on newly added configuration, hash changes, or high-risk fields.

    High-risk fields include pre/post-install hooks, network proxies, dependency registries, credential environment variables, auto-execution commands, and external script URLs. Configuration files should be read-only where possible, with changes requiring approval and leaving an audit trail.

    2.3 Prompt-Execution Separation: Prompts Are Not a Security Boundary

    “Do not execute” written in a prompt is just one instruction in the model’s context; “execution welcome” written in a configuration file may be treated by the agent as project specification. When the two conflict, you cannot rely on the model to adjudicate. The correct approach is to move policy decisions outside the model: the executor denies installation, networking, global configuration changes, and sensitive credential reads by default; when needed, capabilities are granted item by item via capability tokens or human approval. Project instruction files should be treated as untrusted data, not as executable policy.

    2.4 Egress Allowlisting: Deny by Default, Permit on Demand

    The agent’s runtime environment should deny outbound traffic by default, permitting only explicitly defined dependency registries, artifact repositories, and necessary services. DNS, proxies, package manager sources, and raw sockets should all fall under policy. Credentials should be issued with per-task minimal scope, avoiding exposure of long-lived tokens to sessions that instruction files can influence. Alert on anomalous domains, unexpected ports, and high-volume outbound traffic.

    2.5 Rotate on Detection: Front-Load the Response Playbook

    Once configuration drift or a malicious dependency is detected, immediately isolate the session, stop the agent, preserve the scene, rotate tokens and keys, audit global configuration and dependency lockfiles, rebuild the contaminated environment, and trace back launch records from the same directory. The response playbook should make “rotate on detection” explicit—do not wait for confirmed data exfiltration before acting.

    3. Configuration Drift Check Pseudocode

    The following language-agnostic pseudocode can be embedded in local pre-launch checks and CI gates:

    1. BASELINE = load("config-baseline")
    2. CURRENT = scan([
    3. "global-agent-config",
    4. "project-instruction-file",
    5. "package-manager-config",
    6. "build-hook-config",
    7. "env-config"
    8. ])
    9. for path in CURRENT:
    10. if path not in BASELINE:
    11. report("new configuration", path)
    12. else if hash(CURRENT[path]) != BASELINE[path].hash:
    13. report("configuration changed", path)
    14. for key in risky_keys(CURRENT[path]):
    15. if key in ["install_hook", "network_proxy", "registry",
    16. "exec_before", "exec_after", "credential_env"]:
    17. report("high-risk field", path, key)
    18. if any_blocking_finding():
    19. block_start()
    20. require_approval()

    This check cannot replace runtime protection, but it turns “the configuration file quietly changed” from an invisible problem into a blockable one.

    4. Control Mapping Table

    Risk Point Check Item Failure Handling Evidence Retention
    Launch from untrusted directory Is the resolved working directory path on the allowlist Block launch Original path, resolved path, launch source
    Global configuration rewritten Have baseline hash and high-risk keys changed Block and roll back Before/after diff, operator identity
    Prompt-config conflict Are there install, network, or config-change instructions Deny by default, escalate to human approval Instruction fragment, matched policy rule
    Malicious dependency introduced Are dependency source, lockfile, and install hooks compliant Stop installation and isolate Package name, source URL, hook content
    Anomalous outbound traffic Is the egress target on the allowlist Disconnect and alert DNS, IP, port, session identifier

    Conclusion

    The real lesson of this class of problem is not “some agent is insecure,” but rather: do not treat prompts as a security boundary, do not treat the downloads folder as a workspace, do not treat configuration files as trusted input, and do not treat an agent’s self-modification as a convenience. Turning entry control, configuration integrity, prompt-execution separation, egress allowlisting, and rotate-on-detection into gates is how you keep the “prompt says don’t execute, config says execute welcome” crack outside your development environment.