Skip to content

Commit 649770f

Browse files
authored
feedback from security review (#10)
Merged: 2025-11-12 11:41:09
1 parent fc8e4ac commit 649770f

File tree

12 files changed

+239
-159
lines changed

12 files changed

+239
-159
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Global owners
2+
* @docker/ai-agent-team

.github/ISSUE_TEMPLATE/bug-.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Bug!
3+
about: Create a report to help us squash the bugs
4+
title: "<short bug description>"
5+
labels: kind/bug
6+
assignees: ""
7+
---
8+
9+
**Describe the bug**
10+
11+
A clear and concise description of what the bug is.
12+
13+
**Version affected**
14+
15+
Please include the version of the action that you are using.
16+
17+
**How To Reproduce**
18+
19+
Detailed steps to reproduce the behavior:
20+
21+
1. Run workflow '...'
22+
2. Wait for job '...'
23+
3. See error
24+
25+
**Expectation**
26+
27+
A clear and concise description of what you expected to see/happen.
28+
29+
**Screenshots**
30+
31+
If applicable, add screenshots to help explain your problem.
32+
33+
**Additional context**
34+
35+
Any other info you consider useful can be included here

.github/ISSUE_TEMPLATE/feature-.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Feature!
3+
about: Suggest a new feature you'd like to see
4+
title: "<your feature>"
5+
labels: kind/feature
6+
assignees: ""
7+
---
8+
9+
**What you'd like to see**
10+
11+
Describe in as much detail as possible the feature you'd like to see.
12+
Please limit this to a single small feature whenever possible to ease development and contribution efforts.
13+
14+
**Why you'd like to see it**
15+
16+
Tell us why it's important for you.
17+
`x` thing would help me do '...'
18+
`y` feature frustrates me.
19+
`z` feature would get rid of these issues '...'
20+
21+
**Workarounds?**
22+
23+
Are you using any workarounds at the moment? If so, tell us about them.
24+
25+
**Additional context**
26+
27+
Any other info you consider useful can be included here.

.github/SECURITY.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Security Policy
2+
3+
The maintainers of the Docker `cagent` GitHub Action take security seriously. If you discover a security issue, please bring it to their attention right away!
4+
5+
## Reporting a Vulnerability
6+
7+
Please **DO NOT** file a public issue, instead send your report privately to [security@docker.com](mailto:security@docker.com).
8+
9+
Reporter(s) can expect a response within 72 hours, acknowledging the issue was received.
10+
11+
## Review Process
12+
13+
After receiving the report, an initial triage and technical analysis is performed to confirm the report and determine its scope. We may request additional information in this stage of the process.
14+
15+
Once a reviewer has confirmed the relevance of the report, a draft security advisory will be created on GitHub. The draft advisory will be used to discuss the issue with maintainers, the reporter(s), and where applicable, other affected parties under embargo.
16+
17+
If the vulnerability is accepted, a timeline for developing a patch, public disclosure, and patch release will be determined. If there is an embargo period on public disclosure before the patch release, the reporter(s) are expected to participate in the discussion of the timeline and abide by agreed upon dates for public disclosure.
18+
19+
## Accreditation
20+
21+
Security reports are greatly appreciated and we will publicly thank you, although we will keep your name confidential if you request it. We also like to send gifts - if you're into swag, make sure to let us know. We do not currently offer a paid security bounty program at this time.
22+
23+
## Further Information
24+
25+
Should anything in this document be unclear or if you are looking for additional information about how Docker reviews and responds to security vulnerabilities, please take a look at Docker's [Vulnerability Disclosure Policy](https://www.docker.com/trust/vulnerability-disclosure-policy/).

.github/workflows/security-scan.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Security Scan
33
on:
44
schedule:
55
# Run every Monday at 9:00 AM UTC
6-
- cron: "0 9 * * 1"
6+
- cron: "43 1 * * 1"
77
workflow_dispatch:
88
inputs:
99
days_back:
@@ -17,15 +17,16 @@ permissions:
1717

1818
jobs:
1919
security-scan:
20+
name: Security Scan with cagent
2021
runs-on: ubuntu-latest
2122
permissions:
2223
contents: read
2324
issues: write
2425
steps:
2526
- name: Check out Git repository
26-
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2728
with:
28-
fetch-depth: 0 # Need full history to get commits from past week
29+
fetch-depth: 0 # Need full history to get commits from past week
2930

3031
- name: Get commits from past week
3132
id: commits
@@ -107,7 +108,7 @@ jobs:
107108
agent: agentcatalog/github-action-security-scanner
108109
prompt: ${{ steps.commits.outputs.prompt }}
109110
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
110-
timeout: 300 # 5 minutes
111+
timeout: 300 # 5 minutes
111112

112113
- name: Validate reported file paths
113114
id: validate

action.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,6 @@ runs:
151151
# Run sanitization which outputs risk-level and blocked status
152152
$ACTION_PATH/security/sanitize-input.sh /tmp/prompt-input.txt /tmp/prompt-clean.txt
153153
154-
- name: Check prompt for suspicious patterns
155-
if: inputs.prompt != ''
156-
id: sanitize-prompt
157-
shell: bash
158-
env:
159-
PROMPT_INPUT: ${{ inputs.prompt }}
160-
ACTION_PATH: ${{ github.action_path }}
161-
run: |
162-
echo "🔍 Additional prompt pattern checking..."
163-
# Use environment variable to safely pass prompt (avoids GitHub Actions expansion issues)
164-
printf '%s\n' "$PROMPT_INPUT" | $ACTION_PATH/security/sanitize-prompt.sh
165-
166154
- name: Cache cagent binary
167155
id: cache-cagent
168156
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0

security/README.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,30 @@ SECRET_PATTERNS=(
9696
- `leaked=true/false` to `$GITHUB_OUTPUT`
9797
- Exits with code 1 if secrets detected
9898

99-
### `sanitize-prompt.sh`
99+
### `sanitize-input.sh`
100100

101-
**Purpose:** Prompt sanitization for general agent mode
101+
**Purpose:** Input sanitization for PR diffs and user prompts
102102

103103
**Function:**
104-
- Warns about suspicious patterns in user prompts
105-
- Detects prompt injection attempts
106-
- Checks for encoded content
107-
108-
**Note:** This is warning-only (execution continues) unlike input sanitization which blocks
104+
- Removes code comments from diffs (prevents hidden instructions)
105+
- Detects HIGH-RISK patterns (blocks execution)
106+
- Instruction override attempts ("ignore previous instructions")
107+
- Direct secret extraction commands (`echo $API_KEY`, `console.log(process.env)`)
108+
- System prompt extraction attempts
109+
- Jailbreak attempts
110+
- Encoding/obfuscation (base64, hex)
111+
- Detects MEDIUM-RISK patterns (warns but allows execution)
112+
- API key variable names in configuration
109113

110114
**Usage:**
111115
```bash
112-
./sanitize-prompt.sh "User prompt here"
116+
./sanitize-input.sh input-file.txt output-file.txt
113117
```
114118

115119
**Outputs:**
116-
- `suspicious=true/false` to `$GITHUB_OUTPUT`
117-
- Exits with code 0 (warnings only)
120+
- `blocked=true/false` to `$GITHUB_OUTPUT`
121+
- `risk-level=low/medium/high` to `$GITHUB_OUTPUT`
122+
- Exits with code 1 if HIGH-RISK patterns detected
118123

119124
## Built-in Protections
120125

@@ -138,7 +143,7 @@ SECRET_PATTERNS=(
138143
```bash
139144
cd tests
140145

141-
# Run security test suite (10 tests)
146+
# Run security test suite (13 tests)
142147
./test-security.sh
143148

144149
# Run exploit simulation tests (6 tests)
@@ -147,21 +152,25 @@ cd tests
147152

148153
### Test Coverage
149154

150-
**test-security.sh** (10 tests):
155+
**test-security.sh** (13 tests):
151156
1. Clean input (should pass)
152157
2. Prompt injection in comment (should block)
153158
3. Clean output (should pass)
154159
4. Leaked API key (should block)
155160
5. Leaked GitHub token (should block)
156161
6. Authorization - OWNER (should pass)
157-
7. Authorization - CONTRIBUTOR (should block)
158-
8. Clean prompt (should pass)
159-
9. Prompt injection in user prompt (should warn)
160-
10. Encoded content in prompt (should warn)
162+
7. Authorization - COLLABORATOR (should pass)
163+
8. Authorization - CONTRIBUTOR (should block)
164+
9. Clean prompt (should pass)
165+
10. Prompt injection in user prompt (should block)
166+
11. Encoded content in prompt (should block)
167+
12. Low risk input - normal code (should pass)
168+
13. Medium risk input - API key variable (should warn but pass)
169+
14. High risk input - behavioral injection (should block)
161170

162171
**test-exploits.sh** (6 tests):
163-
1. Prompt injection via comment (should be blocked)
164-
2. Encoded base64 injection (should be blocked)
172+
1. Prompt injection via comment (should be stripped)
173+
2. High-risk behavioral injection (should be blocked)
165174
3. Output token leak (should be blocked)
166175
4. Prompt override attempt (should warn)
167176
5. Extra args parsing sanity check

security/sanitize-input.sh

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
2-
# Sanitize PR input by removing code comments and blocking suspicious patterns
3-
# This prevents prompt injection attacks hidden in code comments
2+
# Sanitize input by removing code comments and blocking suspicious patterns
3+
# This prevents prompt injection attacks hidden in code comments or user prompts
44

55
set -e
66

@@ -32,15 +32,72 @@ rm -f "$OUTPUT.bak"
3232
# Define HIGH-RISK patterns that strongly indicate prompt injection attempts
3333
# These are behavioral instructions that shouldn't appear in normal code
3434
HIGH_RISK_PATTERNS=(
35+
# Instruction override attempts
3536
"ignore.*previous.*instruction"
37+
"ignore.*all.*instruction"
38+
"disregard.*previous"
39+
"forget.*previous"
40+
"new.*instruction.*follow"
41+
42+
# System/mode override attempts
3643
"system.*override"
44+
"system.*mode"
45+
"admin.*mode"
3746
"debug.*mode.*enable"
38-
"print.*environment.*variable"
39-
"echo.*\\\$ANTHROPIC_API_KEY"
40-
"echo.*\\\$GITHUB_TOKEN"
41-
"echo.*\\\$OPENAI_API_KEY"
42-
"console\\.log.*process\\.env"
47+
"debug.*mode"
48+
"developer.*mode"
49+
50+
# Direct secret extraction commands - shell
51+
"echo.*\\\$.*ANTHROPIC_API_KEY"
52+
"echo.*\\\$.*GITHUB_TOKEN"
53+
"echo.*\\\$.*OPENAI_API_KEY"
54+
"echo.*\\\$.*GOOGLE_API_KEY"
55+
56+
# Direct secret extraction commands - Python
57+
"print\(.*ANTHROPIC_API_KEY"
58+
"print\(.*OPENAI_API_KEY"
59+
"print\(.*GITHUB_TOKEN"
60+
"print\(.*GOOGLE_API_KEY"
4361
"print.*os\\.environ"
62+
63+
# Direct secret extraction commands - JavaScript
64+
"console\\.log.*process\\.env"
65+
"console\\.log\(.*ANTHROPIC_API_KEY"
66+
"console\\.log\(.*OPENAI_API_KEY"
67+
"console\\.log\(.*GITHUB_TOKEN"
68+
"console\\.log\(.*GOOGLE_API_KEY"
69+
70+
# Environment variable extraction
71+
"print.*environment.*variable"
72+
"printenv[[:space:]]+(ANTHROPIC_API_KEY|OPENAI_API_KEY|GITHUB_TOKEN|GOOGLE_API_KEY)"
73+
74+
# File access to secrets
75+
"cat[[:space:]]+\\.env"
76+
77+
# Direct secret revelation requests
78+
"show.*me.*(your|the|my).*(key|secret|token|api)"
79+
"reveal.*(your|the|my).*(key|secret|token|api)"
80+
"display.*(your|the|my).*(key|secret|token|api)"
81+
"what.*is.*(your|the).*(api.*key|secret|token)"
82+
"give.*me.*(your|the).*(key|secret|token|api)"
83+
84+
# System prompt extraction
85+
"repeat.*system.*prompt"
86+
"what.*are.*your.*instructions"
87+
"show.*initial.*prompt"
88+
"show.*system.*prompt"
89+
90+
# Jailbreak attempts
91+
"act.*as.*no.*restrictions"
92+
"pretend.*to.*be.*evil"
93+
"pretend.*you.*are.*jailbroken"
94+
95+
# Encoding/obfuscation attempts
96+
"base64.*decode"
97+
"decode.*base64"
98+
"atob\("
99+
"btoa\("
100+
"0x[0-9a-fA-F]{20,}"
44101
)
45102

46103
# Define MEDIUM-RISK patterns that warrant warnings but shouldn't block
@@ -49,9 +106,10 @@ MEDIUM_RISK_PATTERNS=(
49106
"ANTHROPIC_API_KEY"
50107
"GITHUB_TOKEN"
51108
"OPENAI_API_KEY"
109+
"GOOGLE_API_KEY"
52110
)
53111

54-
echo "Checking for suspicious patterns..."
112+
echo "🔍 Checking for suspicious patterns..."
55113

56114
FOUND_HIGH_RISK=false
57115
FOUND_MEDIUM_RISK=false
@@ -111,6 +169,12 @@ if [ "$FOUND_HIGH_RISK" = true ]; then
111169
echo "blocked=true" >> "$GITHUB_OUTPUT" || true
112170
echo "risk-level=high" >> "$GITHUB_OUTPUT" || true
113171
fi
172+
echo "::error::═══════════════════════════════════════════════════════
173+
🚨 BLOCKED: HIGH-RISK PROMPT INJECTION DETECTED
174+
═══════════════════════════════════════════════════════
175+
The input contains patterns that strongly indicate a
176+
prompt injection attack. Execution has been blocked.
177+
═══════════════════════════════════════════════════════"
114178
exit 1
115179
fi
116180

0 commit comments

Comments
 (0)