← Back to Pull requests

fix(linter): make owasp-no-credentials-in-url token-aware #253

Closed
unknown closed this pull request without merging on Sep 21, 2026 01:26 UTC
View on GitHub
unknown unknown commented on Sep 20, 2026 06:07 UTC
Author

owasp-no-credentials-in-url matched parameter names with a case-insensitive, unanchored regex, so any name that merely contained secret or token was reported: secretPath, secret_path, tokenId, secretName. A secrets-manager API whose path parameters name the location of a secret could not pass the rule without disabling it for the whole document.

The rule now splits the parameter name into words on _, -, ., digits and camelCase boundaries (acronym runs are handled, so X-API-Key and APIKey both become api, key) and flags the parameter only when the head (last) word is a credential word: secret, token, password, passwd, pwd, or key qualified by api or secret. Glued names such as accesstoken and apikey still match via a suffix check on the head word; the qualified-key forms use the same suffix rule, so myapikey and salesapikey are flagged while monkey and turkey are not. Rule ID, message text, and default severity are unchanged, so existing lint.yaml overrides keep working. As a side effect api_key, passwd and pwd are now flagged where the old regex missed them. Names such as secretValue or passwordHash, where the credential word is not the head, are no longer flagged; that is the trade-off the head-word rule makes, and it is easy to extend if wanted.

Fixes #251

| Parameter name | Before | After |
| --- | --- | --- |
| secretPath | error | ok |
| tokenId | error | ok |
| secretName | error | ok |
| keyName | ok | ok |
| clientSecret | error | error |
| access_token | error | error |
| X-API-Key | error | error |
| api_key | ok | error |
| myapikey | error | error |
| salesapikey | error | error |
| password | error | error |

Testing

$ go test -race -count=1 ./openapi/linter/...
ok  	github.com/speakeasy-api/openapi/openapi/linter	1.334s
ok  	github.com/speakeasy-api/openapi/openapi/linter/converter	1.798s
ok  	github.com/speakeasy-api/openapi/openapi/linter/rules	1.776s

$ gofmt -l ./openapi/linter/rules/
$ go vet ./openapi/linter/...
$ golangci-lint run ./openapi/linter/...
0 issues.
$ nilaway -test=false ./openapi/linter/rules/
$ go run ./cmd/update-lint-docs   # README rules table unchanged

Against the reproduction from the issue, plus tokenId, clientSecret and X-API-Key as query parameters:

$ openapi spec lint owasp.yaml | grep credentials   # before
 7:19 error   owasp-no-credentials-in-url      URL parameter `secretPath` appears to contain credentials - avoid passing sensitive data in URLs
 8:19 error   owasp-no-credentials-in-url      URL parameter `tokenId` appears to contain credentials - avoid passing sensitive data in URLs
 9:19 error   owasp-no-credentials-in-url      URL parameter `clientSecret` appears to contain credentials - avoid passing sensitive data in URLs
10:19 error   owasp-no-credentials-in-url      URL parameter `X-API-Key` appears to contain credentials - avoid passing sensitive data in URLs

$ openapi spec lint owasp.yaml | grep credentials   # after
 9:19 error   owasp-no-credentials-in-url      URL parameter `clientSecret` appears to contain credentials - avoid passing sensitive data in URLs
10:19 error   owasp-no-credentials-in-url      URL parameter `X-API-Key` appears to contain credentials - avoid passing sensitive data in URLs

The new _AllowsDescriptiveNames and _FlagsCredentialNames tables were also run against the old regex to confirm they are load-bearing: every descriptive name failed, and api_key, passwd, pwd failed on the flag side.

Follow-up: glued qualified-key names and fixture quoting

The first cut compared the head word against apikey / secretkey by equality, so a single glued word that merely ends in one of them (myapikey, salesapikey, mysecretkey) fell through, even though the old regex caught it. The qualified-key check now uses the same suffix rule as the other credential words. The lintQueryParameterName test helper also double-quotes the name it splices into its YAML fixture (via strconv.Quote) and asserts the parsed parameter carries the name unchanged, so names containing :, spaces or YAML reserved words cannot break or silently change the fixture.

$ gofmt -l ./openapi/linter/rules/
$ go vet ./openapi/linter/...
$ golangci-lint run ./openapi/linter/...
0 issues.
$ nilaway -test=false ./openapi/linter/rules/
$ go test -race -count=1 ./openapi/linter/...
ok  	github.com/speakeasy-api/openapi/openapi/linter	1.518s
ok  	github.com/speakeasy-api/openapi/openapi/linter/converter	1.266s
ok  	github.com/speakeasy-api/openapi/openapi/linter/rules	1.518s

New table entries: myapikey, salesapikey, mysecretkey, MyAPIKey, mytoken, mysecret, oldpassword must flag; turkey, no, on, null must not (alongside the existing keyName, sortKey, monkey). Run against the previous commit, myapikey, mysecretkey and salesapikey fail on the flag side; with the fixture left unquoted, null fails the new round-trip assertion (the name parses as empty), which is the silent-change case the quoting guards against.

Against a spec with myapikey, salesapikey, keyName and secretPath as query parameters:

$ openapi spec lint glued.yaml | grep credentials   # previous commit
(no output)

$ openapi spec lint glued.yaml | grep credentials   # after
 9:17 error   owasp-no-credentials-in-url      URL parameter `myapikey` appears to contain credentials - avoid passing sensitive data in URLs
13:17 error   owasp-no-credentials-in-url      URL parameter `salesapikey` appears to contain credentials - avoid passing sensitive data in URLs

Diff: 650 lines (+487 / -163) across 8 files Reviewer: david-long1 Review duration: 1158m
All Vouch review confidence checks passed
Residual risk 0.32 = Change Risk (0.75) × (1 − Review Confidence (0.58)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
0.75
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
57%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.388
Shallow Review Depth shallow_review_depth
0.289
Sensitive Paths sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #253"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 58.0% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 75.2% (HIGH) · Higher = larger blast radius
75.2%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 58.0% · Lower = rushed or shallow review
58.0%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 31.6% · Safe to merge
31.6%