T09 · Insecure Skill Coding Practices
- Location
audit_proxy/audit_proxy.py:7- Finding
Proxy Audit Discloses Plaintext Credentials in Its Output
- Content
View full analysis
Vulnerability Details
File Location:
audit_proxy/audit_proxy.py, lines 7–19
Vulnerability Type: Plaintext sensitive-data exposure
Risk Level: MediumVulnerable Code
python def scan_text_for_patterns(text): patterns = { "url_credential_leak": [r"token=", r"gatewayUrl=", r"key=", r"secret=", r"Authorization"], "risky_proxy_to_18789": [r"reverse_proxy\s+(127\.0\.0\.1|localhost):18789", r"proxy_pass\s+http://(127\.0\.0\.1|localhost):18789"] } findings = [] lines = text.splitlines() for i, line in enumerate(lines, 1): for risk_type, ps in patterns.items(): for p in ps: if re.search(p, line, re.IGNORECASE): findings.append(f"[{risk_type}] L{i}: {line.strip()}") return findingsTechnical Analysis
The scanner deliberately searches proxy configuration lines for credential-related markers such as
token=,key=,secret=, andAuthorization. When a match is found, it copies the entire source line into the finding without masking the sensitive value.The findings are subsequently serialized as JSON and written to standard output. As a result, credentials stored in readable Nginx or Caddy configuration files can be propagated into agent context, command logs, audit transcripts, CI logs, or downstream reports. This transforms a credential-detection feature into a secondary disclosure channel.
Attack Path
- A Caddy or Nginx configuration contains a credential on a line matching one of the configured patterns, such as:
nginx proxy_set_header Authorization "Bearer sensitive-token"; - The user or agent invokes
audit_proxy.py. - The scanner reads the configuration and detects
Authorization. - The complete line, including the credential, is added to
findings. - The unredacted finding is emitted through standard output as JSON.
- Any system retaining or displaying tool output receives a copy of the credential.
...[truncated 534 chars]
- A Caddy or Nginx configuration contains a credential on a line matching one of the configured patterns, such as:
- Remediation
View remediation
Remediation Suggestions
- Never include the complete matching configuration line in output.
- Return only the file path, line number, matched credential type, and a sanitized excerpt.
- Redact values following credential-related keys and authorization schemes before serialization.
- Apply masking conservatively, including quoted values, URL query parameters, headers, and whitespace-separated assignments.
- Avoid returning a fixed portion of the original line unless it has first passed through a robust redaction function.
- Add tests covering bearer tokens, basic authorization headers, URL credentials, quoted secrets, and mixed-case key names.
- Ensure downstream audit logs also apply secret redaction.
A safer finding format would be:
python findings.append({ "risk_type": risk_type, "line": i, "detail": "Potential credential detected; value redacted" })
