-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into semgrep-live-PeodN
- Loading branch information
Showing
4 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
37 changes: 37 additions & 0 deletions
37
yaml/openapi/security/api-key-in-query-parameter.test.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Example API | ||
description: Example API | ||
version: 1.0.0 | ||
|
||
servers: | ||
- url: https://api.example.com/ | ||
|
||
paths: | ||
/test/{param}: | ||
get: | ||
operationId: test | ||
parameters: | ||
- name: param | ||
in: path | ||
required: true | ||
description: test | ||
schema: | ||
type: string | ||
|
||
security: | ||
- apiKeyAuthQuery: [] | ||
- apiKeyAuthHeader: [] | ||
|
||
components: | ||
securitySchemes: | ||
# ruleid: api-key-in-query-parameter | ||
apiKeyAuthQuery: | ||
type: apiKey | ||
in: query | ||
name: api_key | ||
# ok: api-key-in-query-parameter | ||
apiKeyAuthHeader: | ||
type: apiKey | ||
in: header | ||
name: X-API-Key |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
rules: | ||
- id: api-key-in-query-parameter | ||
languages: [yaml] | ||
message: >- | ||
The $SECURITY_SCHEME security scheme passes an API key in a query parameter. | ||
API keys should not be passed as query parameters in security schemes. | ||
Pass the API key in the header or body. | ||
If using a query parameter is necessary, ensure that the API key is tightly scoped and short lived. | ||
severity: ERROR | ||
patterns: | ||
- pattern-inside: | | ||
openapi: $VERSION | ||
... | ||
components: | ||
... | ||
securitySchemes: | ||
... | ||
- metavariable-regex: | ||
metavariable: $VERSION | ||
regex: 3.* | ||
- pattern: | | ||
$SECURITY_SCHEME: | ||
... | ||
type: apiKey | ||
... | ||
in: query | ||
metadata: | ||
category: security | ||
subcategory: | ||
- vuln | ||
technology: | ||
- openapi | ||
likelihood: MEDIUM | ||
impact: HIGH | ||
confidence: HIGH | ||
cwe: 'CWE-598: Use of GET Request Method With Sensitive Query Strings' | ||
owasp: | ||
- 'A04:2021 Insecure Design' | ||
- 'A07:2021 Identification and Authentication Failures' | ||
references: | ||
- https://datatracker.ietf.org/doc/html/rfc6749 | ||
- https://cwe.mitre.org/data/definitions/598.html | ||
- https://owasp.org/Top10/A04_2021-Insecure_Design/ | ||
- https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/ |
This file contains 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