@arsh342/athena 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -34
- package/dist/data/popular-crates.json +1 -0
- package/dist/data/popular-npm.json +1 -0
- package/dist/data/popular-nuget.json +1 -0
- package/dist/data/popular-packagist.json +1 -0
- package/dist/data/popular-pypi.json +1 -0
- package/dist/index.cjs +27682 -7864
- package/dist/models/fast/athena-detect-fast-0.1.0.bin +0 -0
- package/dist/models/fast/athena-detect-fast-0.1.0.json +259 -0
- package/dist/skills/.athena-builtin +1 -0
- package/dist/skills/ai-generated-code/SKILL.md +40 -0
- package/dist/skills/ai-generated-code/fixtures/safe/a.go +4 -0
- package/dist/skills/ai-generated-code/fixtures/safe/a.js +2 -0
- package/dist/skills/ai-generated-code/fixtures/safe/a.py +1 -0
- package/dist/skills/ai-generated-code/fixtures/vuln/a.go +4 -0
- package/dist/skills/ai-generated-code/fixtures/vuln/a.js +2 -0
- package/dist/skills/ai-generated-code/fixtures/vuln/a.py +1 -0
- package/dist/skills/ai-generated-code/rules.json +54 -0
- package/dist/skills/aspnet/SKILL.md +41 -0
- package/dist/skills/aspnet/fixtures/safe/Startup.cs +9 -0
- package/dist/skills/aspnet/fixtures/vuln/Startup.cs +9 -0
- package/dist/skills/aspnet/rules.json +46 -0
- package/dist/skills/audit-context/SKILL.md +38 -0
- package/dist/skills/auth-sessions/SKILL.md +39 -0
- package/dist/skills/auth-sessions/fixtures/safe/a.js +3 -0
- package/dist/skills/auth-sessions/fixtures/safe/a.py +2 -0
- package/dist/skills/auth-sessions/fixtures/vuln/a.js +3 -0
- package/dist/skills/auth-sessions/fixtures/vuln/a.py +2 -0
- package/dist/skills/auth-sessions/rules.json +95 -0
- package/dist/skills/c-memory-safety/SKILL.md +35 -0
- package/dist/skills/c-memory-safety/fixtures/safe/a.c +5 -0
- package/dist/skills/c-memory-safety/fixtures/vuln/a.c +6 -0
- package/dist/skills/c-memory-safety/rules.json +54 -0
- package/dist/skills/differential-review/SKILL.md +37 -0
- package/dist/skills/django/SKILL.md +42 -0
- package/dist/skills/django/fixtures/safe/settings.py +3 -0
- package/dist/skills/django/fixtures/vuln/settings.py +2 -0
- package/dist/skills/django/fixtures/vuln/views.py +4 -0
- package/dist/skills/django/rules.json +59 -0
- package/dist/skills/docker/SKILL.md +36 -0
- package/dist/skills/docker/fixtures/safe/Dockerfile +4 -0
- package/dist/skills/docker/fixtures/safe/Dockerfile.multi +6 -0
- package/dist/skills/docker/fixtures/safe/app.dockerfile +3 -0
- package/dist/skills/docker/fixtures/vuln/Dockerfile +3 -0
- package/dist/skills/docker/rules.json +82 -0
- package/dist/skills/efcore/SKILL.md +40 -0
- package/dist/skills/efcore/fixtures/safe/Repo.cs +6 -0
- package/dist/skills/efcore/fixtures/vuln/Repo.cs +6 -0
- package/dist/skills/efcore/rules.json +28 -0
- package/dist/skills/express/SKILL.md +42 -0
- package/dist/skills/express/fixtures/safe/app.js +8 -0
- package/dist/skills/express/fixtures/vuln/app.js +6 -0
- package/dist/skills/express/rules.json +102 -0
- package/dist/skills/false-positive-check/SKILL.md +38 -0
- package/dist/skills/fastapi/SKILL.md +40 -0
- package/dist/skills/fastapi/fixtures/safe/main.py +4 -0
- package/dist/skills/fastapi/fixtures/vuln/main.py +4 -0
- package/dist/skills/fastapi/rules.json +32 -0
- package/dist/skills/file-uploads/SKILL.md +38 -0
- package/dist/skills/file-uploads/fixtures/safe/up.js +5 -0
- package/dist/skills/file-uploads/fixtures/safe/up.py +6 -0
- package/dist/skills/file-uploads/fixtures/vuln/up.js +5 -0
- package/dist/skills/file-uploads/fixtures/vuln/up.py +5 -0
- package/dist/skills/file-uploads/rules.json +52 -0
- package/dist/skills/file-uploads/taint.json +21 -0
- package/dist/skills/flask/SKILL.md +41 -0
- package/dist/skills/flask/fixtures/safe/app.py +5 -0
- package/dist/skills/flask/fixtures/vuln/app.py +5 -0
- package/dist/skills/flask/rules.json +46 -0
- package/dist/skills/github-actions/SKILL.md +36 -0
- package/dist/skills/github-actions/fixtures/safe/.github/workflows/ci.yml +16 -0
- package/dist/skills/github-actions/fixtures/vuln/.github/workflows/ci.yml +12 -0
- package/dist/skills/github-actions/rules.json +85 -0
- package/dist/skills/go-web/SKILL.md +42 -0
- package/dist/skills/go-web/fixtures/safe/main.go +13 -0
- package/dist/skills/go-web/fixtures/vuln/main.go +8 -0
- package/dist/skills/go-web/rules.json +29 -0
- package/dist/skills/go-web/taint.json +14 -0
- package/dist/skills/gorm/SKILL.md +40 -0
- package/dist/skills/gorm/fixtures/safe/q.go +5 -0
- package/dist/skills/gorm/fixtures/vuln/q.go +5 -0
- package/dist/skills/gorm/rules.json +32 -0
- package/dist/skills/hibernate/SKILL.md +43 -0
- package/dist/skills/hibernate/fixtures/safe/Dao.java +6 -0
- package/dist/skills/hibernate/fixtures/vuln/Dao.java +6 -0
- package/dist/skills/hibernate/rules.json +28 -0
- package/dist/skills/insecure-defaults/SKILL.md +35 -0
- package/dist/skills/insecure-defaults-code/SKILL.md +37 -0
- package/dist/skills/insecure-defaults-code/fixtures/safe/a.js +2 -0
- package/dist/skills/insecure-defaults-code/fixtures/safe/a.py +2 -0
- package/dist/skills/insecure-defaults-code/fixtures/vuln/a.js +1 -0
- package/dist/skills/insecure-defaults-code/fixtures/vuln/a.py +2 -0
- package/dist/skills/insecure-defaults-code/rules.json +24 -0
- package/dist/skills/laravel/SKILL.md +41 -0
- package/dist/skills/laravel/fixtures/safe/User.php +5 -0
- package/dist/skills/laravel/fixtures/safe/app/Http/Middleware/VerifyCsrfToken.php +4 -0
- package/dist/skills/laravel/fixtures/safe/resources/views/a.blade.php +2 -0
- package/dist/skills/laravel/fixtures/vuln/User.php +5 -0
- package/dist/skills/laravel/fixtures/vuln/app/Http/Middleware/VerifyCsrfToken.php +4 -0
- package/dist/skills/laravel/fixtures/vuln/resources/views/a.blade.php +1 -0
- package/dist/skills/laravel/rules.json +62 -0
- package/dist/skills/lifecycle-and-races/SKILL.md +40 -0
- package/dist/skills/llm-app-security/SKILL.md +45 -0
- package/dist/skills/llm-app-security/fixtures/safe/a.js +6 -0
- package/dist/skills/llm-app-security/fixtures/safe/a.py +3 -0
- package/dist/skills/llm-app-security/fixtures/vuln/a.js +6 -0
- package/dist/skills/llm-app-security/fixtures/vuln/a.py +3 -0
- package/dist/skills/llm-app-security/rules.json +51 -0
- package/dist/skills/nestjs/SKILL.md +41 -0
- package/dist/skills/nestjs/fixtures/safe/main.ts +7 -0
- package/dist/skills/nestjs/fixtures/vuln/main.ts +5 -0
- package/dist/skills/nestjs/rules.json +47 -0
- package/dist/skills/nextjs/SKILL.md +41 -0
- package/dist/skills/nextjs/fixtures/safe/page.js +2 -0
- package/dist/skills/nextjs/fixtures/vuln/page.js +2 -0
- package/dist/skills/nextjs/rules.json +48 -0
- package/dist/skills/payments-webhooks/SKILL.md +35 -0
- package/dist/skills/payments-webhooks/fixtures/safe/hook.js +5 -0
- package/dist/skills/payments-webhooks/fixtures/vuln/hook.js +4 -0
- package/dist/skills/payments-webhooks/rules.json +33 -0
- package/dist/skills/php-hardening/SKILL.md +36 -0
- package/dist/skills/php-hardening/fixtures/safe/a.php +3 -0
- package/dist/skills/php-hardening/fixtures/vuln/a.php +3 -0
- package/dist/skills/php-hardening/rules.json +42 -0
- package/dist/skills/prisma/SKILL.md +41 -0
- package/dist/skills/prisma/fixtures/safe/q.js +2 -0
- package/dist/skills/prisma/fixtures/vuln/q.js +2 -0
- package/dist/skills/prisma/rules.json +28 -0
- package/dist/skills/react/SKILL.md +40 -0
- package/dist/skills/react/fixtures/safe/a.jsx +2 -0
- package/dist/skills/react/fixtures/vuln/a.jsx +2 -0
- package/dist/skills/react/rules.json +47 -0
- package/dist/skills/rust-unsafe-ffi/SKILL.md +35 -0
- package/dist/skills/rust-unsafe-ffi/fixtures/safe/a.rs +3 -0
- package/dist/skills/rust-unsafe-ffi/fixtures/vuln/a.rs +7 -0
- package/dist/skills/rust-unsafe-ffi/rules.json +41 -0
- package/dist/skills/rust-web/SKILL.md +45 -0
- package/dist/skills/rust-web/fixtures/safe/main.rs +4 -0
- package/dist/skills/rust-web/fixtures/vuln/main.rs +4 -0
- package/dist/skills/rust-web/rules.json +22 -0
- package/dist/skills/sharp-edges/SKILL.md +34 -0
- package/dist/skills/sharp-edges-code/SKILL.md +35 -0
- package/dist/skills/sharp-edges-code/fixtures/safe/a.py +3 -0
- package/dist/skills/sharp-edges-code/fixtures/vuln/a.py +2 -0
- package/dist/skills/sharp-edges-code/rules.json +23 -0
- package/dist/skills/shell-hardening/SKILL.md +35 -0
- package/dist/skills/shell-hardening/fixtures/safe/a.sh +3 -0
- package/dist/skills/shell-hardening/fixtures/vuln/a.sh +2 -0
- package/dist/skills/shell-hardening/rules.json +29 -0
- package/dist/skills/spec-vs-code/SKILL.md +34 -0
- package/dist/skills/spring/SKILL.md +45 -0
- package/dist/skills/spring/fixtures/safe/Sec.java +7 -0
- package/dist/skills/spring/fixtures/safe/src/main/resources/application.properties +1 -0
- package/dist/skills/spring/fixtures/vuln/Sec.java +8 -0
- package/dist/skills/spring/fixtures/vuln/src/main/resources/application.properties +1 -0
- package/dist/skills/spring/rules.json +75 -0
- package/dist/skills/sqlalchemy/SKILL.md +40 -0
- package/dist/skills/sqlalchemy/fixtures/safe/q.py +3 -0
- package/dist/skills/sqlalchemy/fixtures/vuln/q.py +3 -0
- package/dist/skills/sqlalchemy/rules.json +28 -0
- package/dist/skills/typeorm/SKILL.md +40 -0
- package/dist/skills/typeorm/fixtures/safe/q.ts +4 -0
- package/dist/skills/typeorm/fixtures/vuln/q.ts +4 -0
- package/dist/skills/typeorm/rules.json +32 -0
- package/dist/skills/variant-analysis/SKILL.md +38 -0
- package/package.json +11 -2
- package/null-pointer-font/NullPointer-8MpD.ttf +0 -0
- package/null-pointer-font/info.txt +0 -2
- package/null-pointer-font/misc/README.txt +0 -68
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nextjs
|
|
3
|
+
description: 'Next.js: server secrets leaking into the client bundle and risky image settings.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- js
|
|
10
|
+
frameworks:
|
|
11
|
+
- next
|
|
12
|
+
detect:
|
|
13
|
+
dependencies:
|
|
14
|
+
- next
|
|
15
|
+
imports:
|
|
16
|
+
- next
|
|
17
|
+
categories:
|
|
18
|
+
- config
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## When this applies
|
|
22
|
+
|
|
23
|
+
Projects that depend on next.
|
|
24
|
+
|
|
25
|
+
## How to investigate
|
|
26
|
+
|
|
27
|
+
Variables prefixed NEXT_PUBLIC_ are embedded in the browser bundle. Check route handlers and server actions for session checks.
|
|
28
|
+
|
|
29
|
+
## Verification checklist
|
|
30
|
+
|
|
31
|
+
- Is any NEXT_PUBLIC_ variable a secret?
|
|
32
|
+
- Does each route handler check the session?
|
|
33
|
+
|
|
34
|
+
## Fixes
|
|
35
|
+
|
|
36
|
+
Move secrets to server-only variables and read them in route handlers or server actions.
|
|
37
|
+
|
|
38
|
+
## References
|
|
39
|
+
|
|
40
|
+
- https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
|
|
41
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "nextjs.public-env-secret",
|
|
5
|
+
"title": "Secret exposed through a NEXT_PUBLIC_ variable",
|
|
6
|
+
"severity": "MEDIUM",
|
|
7
|
+
"cwe": [
|
|
8
|
+
200,
|
|
9
|
+
540
|
|
10
|
+
],
|
|
11
|
+
"category": "config",
|
|
12
|
+
"why": "NEXT_PUBLIC_ values are inlined into client JavaScript, so anything secret in one is public.",
|
|
13
|
+
"fix": "Rename it without the NEXT_PUBLIC_ prefix and read it only on the server.",
|
|
14
|
+
"match": {
|
|
15
|
+
"kind": "line",
|
|
16
|
+
"line": "process\\.env\\.NEXT_PUBLIC_\\w*(?:SECRET|PRIVATE|PASSWORD|TOKEN|API_?KEY)",
|
|
17
|
+
"where": [
|
|
18
|
+
{
|
|
19
|
+
"op": "lineNotMatches",
|
|
20
|
+
"regex": "PUBLISHABLE|ANON"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"families": [
|
|
25
|
+
"js"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "nextjs.dangerously-allow-svg",
|
|
30
|
+
"title": "SVG optimization enabled for untrusted images",
|
|
31
|
+
"severity": "LOW",
|
|
32
|
+
"cwe": [
|
|
33
|
+
79
|
|
34
|
+
],
|
|
35
|
+
"category": "xss",
|
|
36
|
+
"why": "dangerouslyAllowSVG lets crafted SVG files run script when opened directly.",
|
|
37
|
+
"fix": "Keep it off, or set a strict contentSecurityPolicy for images.",
|
|
38
|
+
"match": {
|
|
39
|
+
"kind": "line",
|
|
40
|
+
"line": "dangerouslyAllowSVG\\s*:\\s*true"
|
|
41
|
+
},
|
|
42
|
+
"families": [
|
|
43
|
+
"js"
|
|
44
|
+
],
|
|
45
|
+
"confidence": "medium"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: payments-webhooks
|
|
3
|
+
description: 'Payment webhooks: signature verification.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- js
|
|
10
|
+
detect:
|
|
11
|
+
always: true
|
|
12
|
+
categories:
|
|
13
|
+
- authn
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## When this applies
|
|
17
|
+
|
|
18
|
+
Code that receives webhooks from payment or SaaS providers.
|
|
19
|
+
|
|
20
|
+
## How to investigate
|
|
21
|
+
|
|
22
|
+
Check that the raw body signature is verified before acting on the event, and that handlers are idempotent.
|
|
23
|
+
|
|
24
|
+
## Verification checklist
|
|
25
|
+
|
|
26
|
+
- Is constructEvent (or an HMAC check) called before using the payload?
|
|
27
|
+
|
|
28
|
+
## Fixes
|
|
29
|
+
|
|
30
|
+
Verify the signature with the provider SDK on the raw body; store processed event ids.
|
|
31
|
+
|
|
32
|
+
## References
|
|
33
|
+
|
|
34
|
+
- https://stripe.com/docs/webhooks/signatures
|
|
35
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "payments-webhooks.webhook-unauthenticated",
|
|
5
|
+
"title": "Webhook route that never verifies a signature",
|
|
6
|
+
"severity": "HIGH",
|
|
7
|
+
"cwe": [
|
|
8
|
+
345
|
|
9
|
+
],
|
|
10
|
+
"category": "authn",
|
|
11
|
+
"why": "Without signature verification anyone can post fake payment events to the route.",
|
|
12
|
+
"fix": "Call stripe.webhooks.constructEvent (or the provider equivalent) on the raw body.",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "call",
|
|
15
|
+
"callee": "^(?:app|router)\\.post$",
|
|
16
|
+
"where": [
|
|
17
|
+
{
|
|
18
|
+
"op": "argMatches",
|
|
19
|
+
"index": 0,
|
|
20
|
+
"regex": "webhook"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"op": "callTextNotMatches",
|
|
24
|
+
"regex": "constructEvent|verifyHeader|signature|hmac"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"families": [
|
|
29
|
+
"js"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: php-hardening
|
|
3
|
+
description: 'PHP pitfalls: legacy eval-like regex flags and loose hash comparison.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- php
|
|
10
|
+
detect:
|
|
11
|
+
always: true
|
|
12
|
+
categories:
|
|
13
|
+
- injection
|
|
14
|
+
- crypto
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## When this applies
|
|
18
|
+
|
|
19
|
+
PHP code.
|
|
20
|
+
|
|
21
|
+
## How to investigate
|
|
22
|
+
|
|
23
|
+
Search for preg_replace with /e, and for == comparisons between hashes ("magic hashes").
|
|
24
|
+
|
|
25
|
+
## Verification checklist
|
|
26
|
+
|
|
27
|
+
- Is a hash compared with == instead of hash_equals?
|
|
28
|
+
|
|
29
|
+
## Fixes
|
|
30
|
+
|
|
31
|
+
Use preg_replace_callback and hash_equals.
|
|
32
|
+
|
|
33
|
+
## References
|
|
34
|
+
|
|
35
|
+
- https://www.php.net/manual/en/function.hash-equals.php
|
|
36
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "php-hardening.preg-replace-eval",
|
|
5
|
+
"title": "preg_replace with the /e modifier",
|
|
6
|
+
"severity": "HIGH",
|
|
7
|
+
"cwe": [
|
|
8
|
+
95
|
|
9
|
+
],
|
|
10
|
+
"category": "injection",
|
|
11
|
+
"why": "The /e modifier evaluates the replacement as PHP code.",
|
|
12
|
+
"fix": "Use preg_replace_callback.",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "line",
|
|
15
|
+
"line": "preg_replace\\(\\s*[\\'\"][^\\'\"]*/[a-z]*e[a-z]*[\\'\"]"
|
|
16
|
+
},
|
|
17
|
+
"families": [
|
|
18
|
+
"php"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "php-hardening.loose-hash-compare",
|
|
23
|
+
"title": "Hash compared with ==",
|
|
24
|
+
"severity": "MEDIUM",
|
|
25
|
+
"cwe": [
|
|
26
|
+
697,
|
|
27
|
+
208
|
|
28
|
+
],
|
|
29
|
+
"category": "crypto",
|
|
30
|
+
"why": "\"0e123\" == \"0e456\" is true in PHP (magic hashes), and == leaks timing.",
|
|
31
|
+
"fix": "Use hash_equals().",
|
|
32
|
+
"match": {
|
|
33
|
+
"kind": "line",
|
|
34
|
+
"line": "(?:md5|sha1|hash)\\(.*\\)\\s*(?:==|!=)\\s*[^=]"
|
|
35
|
+
},
|
|
36
|
+
"families": [
|
|
37
|
+
"php"
|
|
38
|
+
],
|
|
39
|
+
"confidence": "medium"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prisma
|
|
3
|
+
description: 'Prisma: unsafe raw query APIs built from strings.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- js
|
|
10
|
+
frameworks:
|
|
11
|
+
- prisma
|
|
12
|
+
detect:
|
|
13
|
+
dependencies:
|
|
14
|
+
- '@prisma/client'
|
|
15
|
+
- prisma
|
|
16
|
+
imports:
|
|
17
|
+
- '@prisma/client'
|
|
18
|
+
categories:
|
|
19
|
+
- injection
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## When this applies
|
|
23
|
+
|
|
24
|
+
Projects that use prisma.
|
|
25
|
+
|
|
26
|
+
## How to investigate
|
|
27
|
+
|
|
28
|
+
Find raw-query escape hatches and check every one for bound parameters.
|
|
29
|
+
|
|
30
|
+
## Verification checklist
|
|
31
|
+
|
|
32
|
+
- Is the query text a literal? Are values bound separately?
|
|
33
|
+
|
|
34
|
+
## Fixes
|
|
35
|
+
|
|
36
|
+
Use bound parameters or the query builder.
|
|
37
|
+
|
|
38
|
+
## References
|
|
39
|
+
|
|
40
|
+
- https://owasp.org/www-community/attacks/SQL_Injection
|
|
41
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "prisma.unsafe-raw-concat",
|
|
5
|
+
"title": "Prisma raw query built by concatenation",
|
|
6
|
+
"severity": "HIGH",
|
|
7
|
+
"cwe": [
|
|
8
|
+
89
|
|
9
|
+
],
|
|
10
|
+
"category": "injection",
|
|
11
|
+
"why": "$queryRawUnsafe/$executeRawUnsafe run the string as SQL; concatenating values into it is SQL injection.",
|
|
12
|
+
"fix": "Use the tagged template $queryRaw`...${value}` which binds values.",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "call",
|
|
15
|
+
"callee": "\\.\\$(?:queryRawUnsafe|executeRawUnsafe)$",
|
|
16
|
+
"where": [
|
|
17
|
+
{
|
|
18
|
+
"op": "argIsConcat",
|
|
19
|
+
"index": 0
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"families": [
|
|
24
|
+
"js"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react
|
|
3
|
+
description: 'React: unsafe link targets and tab-nabbing.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- js
|
|
10
|
+
frameworks:
|
|
11
|
+
- react
|
|
12
|
+
detect:
|
|
13
|
+
dependencies:
|
|
14
|
+
- react
|
|
15
|
+
imports:
|
|
16
|
+
- react
|
|
17
|
+
categories:
|
|
18
|
+
- xss
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## When this applies
|
|
22
|
+
|
|
23
|
+
Projects that use React.
|
|
24
|
+
|
|
25
|
+
## How to investigate
|
|
26
|
+
|
|
27
|
+
Search JSX for dangerouslySetInnerHTML, javascript: URLs and target="_blank" links.
|
|
28
|
+
|
|
29
|
+
## Verification checklist
|
|
30
|
+
|
|
31
|
+
- Is any URL taken from user data and used in href/src?
|
|
32
|
+
|
|
33
|
+
## Fixes
|
|
34
|
+
|
|
35
|
+
Validate URL schemes (allow http, https, mailto) and add rel="noopener noreferrer".
|
|
36
|
+
|
|
37
|
+
## References
|
|
38
|
+
|
|
39
|
+
- https://react.dev/reference/react-dom/components/common
|
|
40
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "react.target-blank-no-rel",
|
|
5
|
+
"title": "Link opens a new tab without rel=\"noopener\"",
|
|
6
|
+
"severity": "LOW",
|
|
7
|
+
"cwe": [
|
|
8
|
+
1022
|
|
9
|
+
],
|
|
10
|
+
"category": "xss",
|
|
11
|
+
"why": "A page opened with target=\"_blank\" can navigate the opener through window.opener (reverse tab-nabbing).",
|
|
12
|
+
"fix": "Add rel=\"noopener noreferrer\".",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "line",
|
|
15
|
+
"line": "target\\s*=\\s*[\"\\']_blank[\"\\']",
|
|
16
|
+
"where": [
|
|
17
|
+
{
|
|
18
|
+
"op": "lineNotMatches",
|
|
19
|
+
"regex": "rel\\s*=\\s*[\"\\'{][^\"\\']*noopener"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"families": [
|
|
24
|
+
"js"
|
|
25
|
+
],
|
|
26
|
+
"confidence": "medium"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "react.javascript-url",
|
|
30
|
+
"title": "javascript: URL in a link",
|
|
31
|
+
"severity": "MEDIUM",
|
|
32
|
+
"cwe": [
|
|
33
|
+
79
|
|
34
|
+
],
|
|
35
|
+
"category": "xss",
|
|
36
|
+
"why": "A javascript: URL runs script when clicked.",
|
|
37
|
+
"fix": "Use an onClick handler, or validate URL schemes.",
|
|
38
|
+
"match": {
|
|
39
|
+
"kind": "line",
|
|
40
|
+
"line": "(?:href|src|action)\\s*=\\s*\\{?[\"\\'`]javascript:"
|
|
41
|
+
},
|
|
42
|
+
"families": [
|
|
43
|
+
"js"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rust-unsafe-ffi
|
|
3
|
+
description: 'Rust unsafe code and FFI: raw slices and uninitialized memory.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- rust
|
|
10
|
+
detect:
|
|
11
|
+
always: true
|
|
12
|
+
categories:
|
|
13
|
+
- memory-safety
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## When this applies
|
|
17
|
+
|
|
18
|
+
Rust code with unsafe blocks or FFI.
|
|
19
|
+
|
|
20
|
+
## How to investigate
|
|
21
|
+
|
|
22
|
+
Check every from_raw_parts for a valid pointer/length proof and every uninitialized value for full initialization before read.
|
|
23
|
+
|
|
24
|
+
## Verification checklist
|
|
25
|
+
|
|
26
|
+
- Is the invariant written next to the unsafe block?
|
|
27
|
+
|
|
28
|
+
## Fixes
|
|
29
|
+
|
|
30
|
+
Wrap unsafe in a small safe function that checks its inputs.
|
|
31
|
+
|
|
32
|
+
## References
|
|
33
|
+
|
|
34
|
+
- https://doc.rust-lang.org/nomicon/
|
|
35
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "rust-unsafe-ffi.from-raw-parts",
|
|
5
|
+
"title": "Slice built from a raw pointer and length",
|
|
6
|
+
"severity": "MEDIUM",
|
|
7
|
+
"cwe": [
|
|
8
|
+
119
|
|
9
|
+
],
|
|
10
|
+
"category": "memory-safety",
|
|
11
|
+
"why": "from_raw_parts requires a valid, aligned pointer and a length within the allocation; mistakes are memory corruption.",
|
|
12
|
+
"fix": "Prefer safe slices; if unavoidable, check the pointer and length first and document why they hold.",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "call",
|
|
15
|
+
"callee": "(?:^|::)from_raw_parts(?:_mut)?$"
|
|
16
|
+
},
|
|
17
|
+
"families": [
|
|
18
|
+
"rust"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "rust-unsafe-ffi.uninitialized-memory",
|
|
23
|
+
"title": "Uninitialized memory",
|
|
24
|
+
"severity": "LOW",
|
|
25
|
+
"cwe": [
|
|
26
|
+
908
|
|
27
|
+
],
|
|
28
|
+
"category": "memory-safety",
|
|
29
|
+
"why": "mem::uninitialized / zeroed / MaybeUninit::uninit can expose invalid values if read before initialization.",
|
|
30
|
+
"fix": "Use MaybeUninit and write every field before assume_init, or use a default value.",
|
|
31
|
+
"match": {
|
|
32
|
+
"kind": "call",
|
|
33
|
+
"callee": "(?:^|::)(?:uninitialized|zeroed)$|MaybeUninit::uninit$"
|
|
34
|
+
},
|
|
35
|
+
"families": [
|
|
36
|
+
"rust"
|
|
37
|
+
],
|
|
38
|
+
"confidence": "low"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rust-web
|
|
3
|
+
description: 'Rust web services: permissive CORS.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- rust
|
|
10
|
+
frameworks:
|
|
11
|
+
- axum
|
|
12
|
+
- actix
|
|
13
|
+
detect:
|
|
14
|
+
dependencies:
|
|
15
|
+
- axum
|
|
16
|
+
- actix-web
|
|
17
|
+
- tower-http
|
|
18
|
+
imports:
|
|
19
|
+
- axum
|
|
20
|
+
- actix_web
|
|
21
|
+
- tower_http
|
|
22
|
+
categories:
|
|
23
|
+
- cors
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## When this applies
|
|
27
|
+
|
|
28
|
+
Rust services using axum or actix-web.
|
|
29
|
+
|
|
30
|
+
## How to investigate
|
|
31
|
+
|
|
32
|
+
Check CORS layers and extractor-based auth.
|
|
33
|
+
|
|
34
|
+
## Verification checklist
|
|
35
|
+
|
|
36
|
+
- Is any CORS layer permissive in production?
|
|
37
|
+
|
|
38
|
+
## Fixes
|
|
39
|
+
|
|
40
|
+
List origins explicitly.
|
|
41
|
+
|
|
42
|
+
## References
|
|
43
|
+
|
|
44
|
+
- https://docs.rs/tower-http/latest/tower_http/cors/
|
|
45
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "rust-web.permissive-cors",
|
|
5
|
+
"title": "Permissive CORS layer",
|
|
6
|
+
"severity": "MEDIUM",
|
|
7
|
+
"cwe": [
|
|
8
|
+
942
|
|
9
|
+
],
|
|
10
|
+
"category": "cors",
|
|
11
|
+
"why": "permissive() allows any origin, method and header.",
|
|
12
|
+
"fix": "Configure allowed origins.",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "line",
|
|
15
|
+
"line": "(?:Cors|CorsLayer)::permissive\\(\\)|allow_any_origin\\(\\)"
|
|
16
|
+
},
|
|
17
|
+
"families": [
|
|
18
|
+
"rust"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sharp-edges
|
|
3
|
+
description: Error-prone APIs and configurations that look fine but behave dangerously.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
detect:
|
|
9
|
+
always: true
|
|
10
|
+
categories:
|
|
11
|
+
- api-misuse
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## When this applies
|
|
15
|
+
|
|
16
|
+
Reviewing use of APIs with surprising defaults (assert for security, loose comparisons, regex with user patterns).
|
|
17
|
+
|
|
18
|
+
## How to investigate
|
|
19
|
+
|
|
20
|
+
List the language and framework APIs with surprising defaults and check each use against the safe form.
|
|
21
|
+
|
|
22
|
+
## Verification checklist
|
|
23
|
+
|
|
24
|
+
- Is a security decision made by `assert`, loose equality or a type coercion?
|
|
25
|
+
- Is user input used as a pattern, format string or path?
|
|
26
|
+
|
|
27
|
+
## Fixes
|
|
28
|
+
|
|
29
|
+
Replace with the explicit safe API and add a test for the dangerous input.
|
|
30
|
+
|
|
31
|
+
## References
|
|
32
|
+
|
|
33
|
+
- https://owasp.org/
|
|
34
|
+
|