Repository navigation
feat(redact): close crypto-suffix identifier + webhook-URL gaps - #79
Open
swarit-stepsecurity wants to merge 2 commits into
Open
swarit-stepsecurity wants to merge 2 commits into
swarit-stepsecurity wants to merge 2 commits into
Conversation
Two narrow extensions to the redactor, motivated by a stress-test
audit:
1. Identifiers that *contain* a credential word but don't end on it
(passwordHash, apiKeyDigest, accessTokenHmac, ...) slipped past
secret_assignment because the existing rule anchored on the
credential word ending the identifier. New rule
`secret_assignment_crypto_suffix` matches the same prefix shape
with a tight allowed-suffix list (HASH/HASHED/DIGEST/HMAC/
CIPHER/ENCRYPTED/SIGNATURE/SALT/SALTED). The suffix list is
intentionally narrow so non-credential names like `passwordless`,
`tokenize`, `secretary`, and `tokenization_enabled` stay
non-redacted (covered by TestStringPreservesNonCredentialNeighbors).
2. Webhook URLs carry their auth in the path; the URL itself is
credential-grade. Added three rules:
- slack_webhook_url: hooks.slack.com/{services,workflows}/...
- discord_webhook_url: discord.com/api/webhooks/<id>/<token>
- teams_webhook_url: *.webhook.office.com / outlook.office.com
Tests cover both directions — the new shapes are redacted, and the
adjacent-but-non-credential shapes stay intact.
There was a problem hiding this comment.
🟡 Changes recommended
Critical redaction gaps still expose secrets in quoted password-hash values, webhook tokens ending in hyphens, and webhook URLs with mixed-case schemes or hostnames.
3 open issues
What changed in this PR
This PR extends the AI-agent redactor to cover crypto-suffixed credential identifiers and webhook URLs whose paths contain authentication secrets.
Changes:
- Adds a narrow suffix rule for identifiers such as
passwordHashandapiKeyDigest. - Adds webhook URL redaction for Slack, Discord, and Microsoft Teams.
- Adds tests for the new credential shapes and preservation of similar non-secret identifiers.
| File | Description |
|---|---|
internal/aiagents/redact/redact.go |
Adds crypto-suffix assignment and webhook URL rules. |
internal/aiagents/redact/redact_test.go |
Adds redaction tests and non-credential false-positive guards. |
Review effort: Balanced
| // HMAC is still credential-grade — leaking either feeds offline attacks. | ||
| { | ||
| name: "secret_assignment_crypto_suffix", | ||
| re: regexp.MustCompile(`(?i)\b([A-Z0-9_]*(?:PASSWORD|PASSWD|SECRET|TOKEN|API[_-]?KEY|ACCESS[_-]?KEY|PRIVATE[_-]?KEY)_?(?:HASH(?:ED|ES)?|DIGEST|HMAC|CIPHER|ENCRYPTED|SIGNATURES?|SALT(?:ED)?))\s*[:=]\s*("?)([^\s"'#]+)`), |
| // Covers discord.com, discordapp.com, and the canary/ptb subdomains. | ||
| { | ||
| name: "discord_webhook_url", | ||
| re: regexp.MustCompile(`\bhttps?://(?:ptb\.|canary\.)?discord(?:app)?\.com/api/(?:v\d+/)?webhooks/\d+/[A-Za-z0-9_\-]{60,}\b`), |
Comment on lines
+204
to
+218
| re: regexp.MustCompile(`\bhttps://hooks\.slack\.com/(?:services|workflows)/[A-Za-z0-9_/\-]+`), | ||
| }, | ||
| // Discord webhook URLs. Token is the last path segment (≥60 chars). | ||
| // Covers discord.com, discordapp.com, and the canary/ptb subdomains. | ||
| { | ||
| name: "discord_webhook_url", | ||
| re: regexp.MustCompile(`\bhttps?://(?:ptb\.|canary\.)?discord(?:app)?\.com/api/(?:v\d+/)?webhooks/\d+/[A-Za-z0-9_\-]{60,}\b`), | ||
| }, | ||
| // Microsoft Teams / Power Automate incoming-webhook URLs. Several | ||
| // tenant-specific subdomain shapes (<tenant>.webhook.office.com, | ||
| // outlook.office.com); the path segments past /webhook/ carry the | ||
| // rotating secret. | ||
| { | ||
| name: "teams_webhook_url", | ||
| re: regexp.MustCompile(`\bhttps://(?:[a-z0-9-]+\.)?(?:webhook\.office|outlook\.office)\.com/(?:webhook(?:b2)?|services/[^/\s]+/IncomingWebhook)/[A-Za-z0-9@/_\-]+\b`), |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Two narrow extensions to the redactor, motivated by a stress-test audit:
Identifiers that contain a credential word but don't end on it (passwordHash, apiKeyDigest, accessTokenHmac, ...) slipped past secret_assignment because the existing rule anchored on the credential word ending the identifier. New rule
secret_assignment_crypto_suffixmatches the same prefix shape with a tight allowed-suffix list (HASH/HASHED/DIGEST/HMAC/ CIPHER/ENCRYPTED/SIGNATURE/SALT/SALTED). The suffix list is intentionally narrow so non-credential names likepasswordless,tokenize,secretary, andtokenization_enabledstay non-redacted (covered by TestStringPreservesNonCredentialNeighbors).Webhook URLs carry their auth in the path; the URL itself is credential-grade. Added three rules: - slack_webhook_url: hooks.slack.com/{services,workflows}/...
Tests cover both directions — the new shapes are redacted, and the adjacent-but-non-credential shapes stay intact.
What does this PR do?
Type of change
Testing
./stepsecurity-dev-machine-guard --verbose./stepsecurity-dev-machine-guard --json | python3 -m json.toolmake lintmake testRelated Issues