807b56bc69
- 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
50 lines
2.4 KiB
Gherkin
50 lines
2.4 KiB
Gherkin
@security @prompt-injection @auto-debug-agent
|
|
Feature: AutoDebugAgent prompt injection vulnerability mitigation
|
|
As a security-conscious developer
|
|
I want AutoDebugAgent to sanitize user-provided content
|
|
So that prompt injection attacks cannot override the agent's instructions
|
|
|
|
@security @prompt-injection
|
|
Scenario: Error message is wrapped with boundary markers
|
|
Given an auto debug agent with a mock LLM
|
|
When I invoke the agent with a normal error message
|
|
Then the error message should be wrapped with USER_CONTENT_START and USER_CONTENT_END markers
|
|
And the system prompt should include the boundary instruction
|
|
|
|
@security @prompt-injection
|
|
Scenario: Code context is wrapped with boundary markers
|
|
Given an auto debug agent with a mock LLM
|
|
When I invoke the agent with code context
|
|
Then the code context should be wrapped with USER_CONTENT_START and USER_CONTENT_END markers
|
|
And the system prompt should include the boundary instruction
|
|
|
|
@security @prompt-injection
|
|
Scenario: Prompt injection attempt in error message is neutralized
|
|
Given an auto debug agent with a mock LLM
|
|
When I invoke the agent with a malicious error message containing "Ignore all previous instructions"
|
|
Then the malicious instruction should be sanitized
|
|
And the agent should continue with its original instructions
|
|
And the boundary markers should protect against the injection
|
|
|
|
@security @prompt-injection
|
|
Scenario: Prompt injection attempt in code context is neutralized
|
|
Given an auto debug agent with a mock LLM
|
|
When I invoke the agent with malicious code context containing "Ignore all previous instructions"
|
|
Then the malicious instruction should be sanitized
|
|
And the agent should continue with its original instructions
|
|
And the boundary markers should protect against the injection
|
|
|
|
@security @prompt-injection
|
|
Scenario: HTML entities in user content are escaped
|
|
Given an auto debug agent with a mock LLM
|
|
When I invoke the agent with error message containing HTML entities
|
|
Then the HTML entities should be escaped in the prompt
|
|
And the boundary markers should be present
|
|
|
|
@security @prompt-injection
|
|
Scenario: Control characters are stripped from user content
|
|
Given an auto debug agent with a mock LLM
|
|
When I invoke the agent with error message containing control characters
|
|
Then the control characters should be removed
|
|
And the boundary markers should be present
|