Files
cleveragents-core/robot/auto_debug_agent_prompt_injection.robot
HAL9000 807b56bc69 fix(agents): sanitize user-provided content in AutoDebugAgent prompts to prevent prompt injection
- Add _sanitize_user_input() helper that catches PromptInjectionDetected and falls back to wrap_user_content() instead of crashing the agent
- Remove dead code (_bs, _be variables) from all three agent methods
- Use wrap_user_content() for error_analysis (internal LLM output) in _generate_fix() to avoid crashing on the agent's own output
- Add @security @prompt-injection BDD tags to feature file and all scenarios
- Add missing @then("the boundary markers should be present") step definition
- Add Robot Framework integration tests (auto_debug_agent_prompt_injection.robot)
- Update CHANGELOG.md and CONTRIBUTORS.md

ISSUES CLOSED: #9110
2026-06-02 17:06:11 -04:00

56 lines
2.6 KiB
Plaintext

*** Settings ***
Documentation AutoDebugAgent prompt injection mitigation — integration smoke tests
Library OperatingSystem
Library Process
Resource ${CURDIR}/common.resource
Suite Setup Setup Test Environment
Suite Teardown Cleanup Test Environment
*** Variables ***
${HELPER_SCRIPT} robot/helper_auto_debug_agent_prompt_injection.py
${SRC_DIR} ${CURDIR}/../src
*** Test Cases ***
AutoDebugAgent Wraps Error Message With Boundary Markers
[Tags] security prompt-injection auto-debug-agent
${result}= Run Process ${PYTHON} ${HELPER_SCRIPT} test-error-boundary-markers
... cwd=${WORKSPACE} env:PYTHONPATH=${SRC_DIR}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} PASS
AutoDebugAgent Wraps Code Context With Boundary Markers
[Tags] security prompt-injection auto-debug-agent
${result}= Run Process ${PYTHON} ${HELPER_SCRIPT} test-code-context-boundary-markers
... cwd=${WORKSPACE} env:PYTHONPATH=${SRC_DIR}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} PASS
AutoDebugAgent Handles Injection In Error Message Gracefully
[Tags] security prompt-injection auto-debug-agent
${result}= Run Process ${PYTHON} ${HELPER_SCRIPT} test-injection-in-error-graceful
... cwd=${WORKSPACE} env:PYTHONPATH=${SRC_DIR}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} PASS
AutoDebugAgent Handles Injection In Code Context Gracefully
[Tags] security prompt-injection auto-debug-agent
${result}= Run Process ${PYTHON} ${HELPER_SCRIPT} test-injection-in-code-graceful
... cwd=${WORKSPACE} env:PYTHONPATH=${SRC_DIR}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} PASS
AutoDebugAgent System Prompt Includes Boundary Instruction
[Tags] security prompt-injection auto-debug-agent
${result}= Run Process ${PYTHON} ${HELPER_SCRIPT} test-system-prompt-boundary-instruction
... cwd=${WORKSPACE} env:PYTHONPATH=${SRC_DIR}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} PASS
AutoDebugAgent Does Not Sanitize Internal LLM Output
[Tags] security prompt-injection auto-debug-agent
${result}= Run Process ${PYTHON} ${HELPER_SCRIPT} test-internal-output-not-sanitized
... cwd=${WORKSPACE} env:PYTHONPATH=${SRC_DIR}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} PASS