@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,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: c-memory-safety
|
|
3
|
+
description: C/C++ memory safety beyond the basic unsafe-function checks.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- c
|
|
10
|
+
detect:
|
|
11
|
+
always: true
|
|
12
|
+
categories:
|
|
13
|
+
- memory-safety
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## When this applies
|
|
17
|
+
|
|
18
|
+
C and C++ code.
|
|
19
|
+
|
|
20
|
+
## How to investigate
|
|
21
|
+
|
|
22
|
+
Look at buffer lengths derived from the source (strlen) instead of the destination, variable-size stack allocations, and manual allocation arithmetic.
|
|
23
|
+
|
|
24
|
+
## Verification checklist
|
|
25
|
+
|
|
26
|
+
- Is the bound the destination size?
|
|
27
|
+
|
|
28
|
+
## Fixes
|
|
29
|
+
|
|
30
|
+
Bound by the destination size, use snprintf, calloc/reallocarray, and heap allocation for variable sizes.
|
|
31
|
+
|
|
32
|
+
## References
|
|
33
|
+
|
|
34
|
+
- https://wiki.sei.cmu.edu/confluence/display/c/
|
|
35
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "c-memory-safety.strncpy-source-length",
|
|
5
|
+
"title": "strncpy bounded by the source length",
|
|
6
|
+
"severity": "MEDIUM",
|
|
7
|
+
"cwe": [
|
|
8
|
+
120,
|
|
9
|
+
806
|
|
10
|
+
],
|
|
11
|
+
"category": "memory-safety",
|
|
12
|
+
"why": "strncpy(dst, src, strlen(src)) copies without room for the terminator and ignores the destination size.",
|
|
13
|
+
"fix": "Bound by sizeof(dst) - 1 and terminate explicitly.",
|
|
14
|
+
"match": {
|
|
15
|
+
"kind": "call",
|
|
16
|
+
"callee": "^strncpy$",
|
|
17
|
+
"where": [
|
|
18
|
+
{
|
|
19
|
+
"op": "argMatches",
|
|
20
|
+
"index": 2,
|
|
21
|
+
"regex": "strlen\\s*\\("
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"families": [
|
|
26
|
+
"c"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "c-memory-safety.alloca-variable-size",
|
|
31
|
+
"title": "alloca with a variable size",
|
|
32
|
+
"severity": "MEDIUM",
|
|
33
|
+
"cwe": [
|
|
34
|
+
770
|
|
35
|
+
],
|
|
36
|
+
"category": "memory-safety",
|
|
37
|
+
"why": "alloca with an attacker-influenced size can overflow the stack.",
|
|
38
|
+
"fix": "Use heap allocation with a checked upper bound.",
|
|
39
|
+
"match": {
|
|
40
|
+
"kind": "call",
|
|
41
|
+
"callee": "^alloca$",
|
|
42
|
+
"where": [
|
|
43
|
+
{
|
|
44
|
+
"op": "argIsNonLiteral",
|
|
45
|
+
"index": 0
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"families": [
|
|
50
|
+
"c"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: differential-review
|
|
3
|
+
description: 'Security-focused review of a change: what did the diff add, remove or relax, and who is affected?'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
detect:
|
|
9
|
+
always: true
|
|
10
|
+
categories:
|
|
11
|
+
- review
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## When this applies
|
|
15
|
+
|
|
16
|
+
Reviewing a pull request or the staged changes before commit.
|
|
17
|
+
|
|
18
|
+
## How to investigate
|
|
19
|
+
|
|
20
|
+
1. Read the diff for removed checks and widened access first.
|
|
21
|
+
2. For each new entry point or query, apply the audit-context steps.
|
|
22
|
+
3. Check whether the change breaks a convention its siblings follow (auth, ownership filter, validation).
|
|
23
|
+
4. Look at git history of the touched lines for earlier fixes being undone.
|
|
24
|
+
|
|
25
|
+
## Verification checklist
|
|
26
|
+
|
|
27
|
+
- Were any guards, validations or limits removed?
|
|
28
|
+
- Does new code follow the sibling conventions?
|
|
29
|
+
|
|
30
|
+
## Fixes
|
|
31
|
+
|
|
32
|
+
Request the missing check in the same change, with a test.
|
|
33
|
+
|
|
34
|
+
## References
|
|
35
|
+
|
|
36
|
+
- https://owasp.org/www-project-code-review-guide/
|
|
37
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: django
|
|
3
|
+
description: 'Django settings: hosts, CSRF and cookie flags.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- python
|
|
10
|
+
frameworks:
|
|
11
|
+
- django
|
|
12
|
+
detect:
|
|
13
|
+
dependencies:
|
|
14
|
+
- django
|
|
15
|
+
imports:
|
|
16
|
+
- django
|
|
17
|
+
categories:
|
|
18
|
+
- config
|
|
19
|
+
- session
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## When this applies
|
|
23
|
+
|
|
24
|
+
Projects that depend on Django.
|
|
25
|
+
|
|
26
|
+
## How to investigate
|
|
27
|
+
|
|
28
|
+
Read settings.py for ALLOWED_HOSTS, cookie flags and csrf_exempt views.
|
|
29
|
+
|
|
30
|
+
## Verification checklist
|
|
31
|
+
|
|
32
|
+
- Is ALLOWED_HOSTS explicit?
|
|
33
|
+
- Are *_COOKIE_SECURE True in production?
|
|
34
|
+
|
|
35
|
+
## Fixes
|
|
36
|
+
|
|
37
|
+
Pin ALLOWED_HOSTS, set cookie flags, avoid csrf_exempt.
|
|
38
|
+
|
|
39
|
+
## References
|
|
40
|
+
|
|
41
|
+
- https://docs.djangoproject.com/en/stable/topics/security/
|
|
42
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "django.allowed-hosts-wildcard",
|
|
5
|
+
"title": "ALLOWED_HOSTS allows every host",
|
|
6
|
+
"severity": "MEDIUM",
|
|
7
|
+
"cwe": [
|
|
8
|
+
183
|
|
9
|
+
],
|
|
10
|
+
"category": "config",
|
|
11
|
+
"why": "A wildcard ALLOWED_HOSTS disables host header validation (cache poisoning, password reset poisoning).",
|
|
12
|
+
"fix": "List the real hostnames.",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "line",
|
|
15
|
+
"line": "ALLOWED_HOSTS\\s*=\\s*\\[\\s*[\\'\"]\\*[\\'\"]"
|
|
16
|
+
},
|
|
17
|
+
"families": [
|
|
18
|
+
"python"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "django.csrf-exempt",
|
|
23
|
+
"title": "View exempt from CSRF protection",
|
|
24
|
+
"severity": "LOW",
|
|
25
|
+
"cwe": [
|
|
26
|
+
352
|
|
27
|
+
],
|
|
28
|
+
"category": "session",
|
|
29
|
+
"why": "csrf_exempt disables CSRF checks for the view.",
|
|
30
|
+
"fix": "Remove it, or authenticate the caller by token instead of cookie.",
|
|
31
|
+
"match": {
|
|
32
|
+
"kind": "line",
|
|
33
|
+
"line": "^\\s*@csrf_exempt\\b"
|
|
34
|
+
},
|
|
35
|
+
"families": [
|
|
36
|
+
"python"
|
|
37
|
+
],
|
|
38
|
+
"confidence": "low"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"id": "django.cookie-not-secure",
|
|
42
|
+
"title": "Session or CSRF cookie not Secure",
|
|
43
|
+
"severity": "MEDIUM",
|
|
44
|
+
"cwe": [
|
|
45
|
+
614
|
|
46
|
+
],
|
|
47
|
+
"category": "session",
|
|
48
|
+
"why": "*_COOKIE_SECURE = False sends the cookie over HTTP.",
|
|
49
|
+
"fix": "Set it to True in production.",
|
|
50
|
+
"match": {
|
|
51
|
+
"kind": "line",
|
|
52
|
+
"line": "(?:SESSION|CSRF)_COOKIE_SECURE\\s*=\\s*False"
|
|
53
|
+
},
|
|
54
|
+
"families": [
|
|
55
|
+
"python"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docker
|
|
3
|
+
description: 'Dockerfiles: root user, remote ADD, floating tags and curl-pipe-shell.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
detect:
|
|
9
|
+
files:
|
|
10
|
+
- (?:^|/)(?:Dockerfile[\w.-]*|[\w.-]+\.dockerfile)$
|
|
11
|
+
categories:
|
|
12
|
+
- container
|
|
13
|
+
- supply-chain
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## When this applies
|
|
17
|
+
|
|
18
|
+
Repositories with Dockerfiles.
|
|
19
|
+
|
|
20
|
+
## How to investigate
|
|
21
|
+
|
|
22
|
+
Check the final stage for a non-root USER, base image tags, ADD of URLs and download-and-run steps.
|
|
23
|
+
|
|
24
|
+
## Verification checklist
|
|
25
|
+
|
|
26
|
+
- Does the container run as root?
|
|
27
|
+
- Is the base image pinned?
|
|
28
|
+
|
|
29
|
+
## Fixes
|
|
30
|
+
|
|
31
|
+
Add a non-root USER, pin base images by version or digest, verify downloads.
|
|
32
|
+
|
|
33
|
+
## References
|
|
34
|
+
|
|
35
|
+
- https://docs.docker.com/develop/security-best-practices/
|
|
36
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "docker.runs-as-root",
|
|
5
|
+
"title": "Container runs as root",
|
|
6
|
+
"severity": "MEDIUM",
|
|
7
|
+
"cwe": [
|
|
8
|
+
250
|
|
9
|
+
],
|
|
10
|
+
"category": "container",
|
|
11
|
+
"why": "Without a USER instruction the process runs as root; a container escape or a file write bug is then much worse.",
|
|
12
|
+
"fix": "Create a user and switch to it with USER.",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "file",
|
|
15
|
+
"files": "(?:^|/)(?:Dockerfile[\\w.-]*|[\\w.-]+\\.dockerfile)$",
|
|
16
|
+
"line": "^\\s*FROM\\s",
|
|
17
|
+
"where": [
|
|
18
|
+
{
|
|
19
|
+
"op": "isLastMatch"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"op": "textAfterNotMatches",
|
|
23
|
+
"regex": "^\\s*USER\\s+(?!root\\b)\\S+"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"op": "lineNotMatches",
|
|
27
|
+
"regex": "nonroot|distroless"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "docker.add-remote-url",
|
|
34
|
+
"title": "ADD downloads from a URL",
|
|
35
|
+
"severity": "MEDIUM",
|
|
36
|
+
"cwe": [
|
|
37
|
+
494
|
|
38
|
+
],
|
|
39
|
+
"category": "supply-chain",
|
|
40
|
+
"why": "ADD of a remote URL fetches content with no checksum verification.",
|
|
41
|
+
"fix": "Use curl/wget with a checksum check in a RUN step.",
|
|
42
|
+
"match": {
|
|
43
|
+
"kind": "file",
|
|
44
|
+
"files": "(?:^|/)(?:Dockerfile[\\w.-]*|[\\w.-]+\\.dockerfile)$",
|
|
45
|
+
"line": "^\\s*ADD\\s+https?://"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "docker.floating-base-tag",
|
|
50
|
+
"title": "Base image without a version",
|
|
51
|
+
"severity": "LOW",
|
|
52
|
+
"cwe": [
|
|
53
|
+
1104
|
|
54
|
+
],
|
|
55
|
+
"category": "supply-chain",
|
|
56
|
+
"why": "FROM image or :latest changes under you and can break or compromise builds.",
|
|
57
|
+
"fix": "Pin a version (and ideally a digest).",
|
|
58
|
+
"match": {
|
|
59
|
+
"kind": "file",
|
|
60
|
+
"files": "(?:^|/)(?:Dockerfile[\\w.-]*|[\\w.-]+\\.dockerfile)$",
|
|
61
|
+
"line": "^\\s*FROM\\s+(?!scratch\\b)(?:[\\w.-]+/[\\w./-]+|(?:node|python|ubuntu|debian|alpine|nginx|golang|openjdk|ruby|php|rust|mysql|postgres|redis|httpd|busybox|centos|fedora|maven|gradle|dotnet))(?::latest)?(?:\\s+AS\\s+\\S+)?\\s*(?:#.*)?$"
|
|
62
|
+
},
|
|
63
|
+
"confidence": "low"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "docker.curl-pipe-shell",
|
|
67
|
+
"title": "Downloaded script piped to a shell",
|
|
68
|
+
"severity": "HIGH",
|
|
69
|
+
"cwe": [
|
|
70
|
+
494
|
|
71
|
+
],
|
|
72
|
+
"category": "supply-chain",
|
|
73
|
+
"why": "Running a script straight from the network executes whatever the server returns.",
|
|
74
|
+
"fix": "Download, verify a checksum or signature, then run.",
|
|
75
|
+
"match": {
|
|
76
|
+
"kind": "file",
|
|
77
|
+
"files": "(?:^|/)(?:Dockerfile[\\w.-]*|[\\w.-]+\\.dockerfile)$",
|
|
78
|
+
"line": "^\\s*RUN\\s.*(?:curl|wget)[^|]*\\|\\s*(?:sudo\\s+)?(?:ba)?sh\\b"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: efcore
|
|
3
|
+
description: 'Entity Framework Core: FromSqlRaw built from strings.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- csharp
|
|
10
|
+
frameworks:
|
|
11
|
+
- efcore
|
|
12
|
+
detect:
|
|
13
|
+
dependencies:
|
|
14
|
+
- microsoft.entityframeworkcore
|
|
15
|
+
imports:
|
|
16
|
+
- Microsoft.EntityFrameworkCore
|
|
17
|
+
categories:
|
|
18
|
+
- injection
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## When this applies
|
|
22
|
+
|
|
23
|
+
Projects that use efcore.
|
|
24
|
+
|
|
25
|
+
## How to investigate
|
|
26
|
+
|
|
27
|
+
Find raw-query escape hatches and check every one for bound parameters.
|
|
28
|
+
|
|
29
|
+
## Verification checklist
|
|
30
|
+
|
|
31
|
+
- Is the query text a literal? Are values bound separately?
|
|
32
|
+
|
|
33
|
+
## Fixes
|
|
34
|
+
|
|
35
|
+
Use bound parameters or the query builder.
|
|
36
|
+
|
|
37
|
+
## References
|
|
38
|
+
|
|
39
|
+
- https://owasp.org/www-community/attacks/SQL_Injection
|
|
40
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "efcore.raw-sql-concat",
|
|
5
|
+
"title": "EF Core raw SQL built by concatenation",
|
|
6
|
+
"severity": "HIGH",
|
|
7
|
+
"cwe": [
|
|
8
|
+
89
|
|
9
|
+
],
|
|
10
|
+
"category": "injection",
|
|
11
|
+
"why": "FromSqlRaw/ExecuteSqlRaw with concatenated text is SQL injection.",
|
|
12
|
+
"fix": "Use FromSqlInterpolated or pass SqlParameter values.",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "call",
|
|
15
|
+
"callee": "\\.(?:FromSqlRaw|ExecuteSqlRaw)$",
|
|
16
|
+
"where": [
|
|
17
|
+
{
|
|
18
|
+
"op": "argIsConcat",
|
|
19
|
+
"index": 0
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"families": [
|
|
24
|
+
"csharp"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: express
|
|
3
|
+
description: 'Express.js hardening: session cookies, static file serving, body limits and fingerprinting.'
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
license: MIT
|
|
6
|
+
author: Athena
|
|
7
|
+
appliesTo:
|
|
8
|
+
languages:
|
|
9
|
+
- js
|
|
10
|
+
frameworks:
|
|
11
|
+
- express
|
|
12
|
+
detect:
|
|
13
|
+
dependencies:
|
|
14
|
+
- express
|
|
15
|
+
imports:
|
|
16
|
+
- express
|
|
17
|
+
categories:
|
|
18
|
+
- session
|
|
19
|
+
- config
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## When this applies
|
|
23
|
+
|
|
24
|
+
Projects that depend on express.
|
|
25
|
+
|
|
26
|
+
## How to investigate
|
|
27
|
+
|
|
28
|
+
Check app setup (helmet, trust proxy), session middleware options, static file options and body parser limits.
|
|
29
|
+
|
|
30
|
+
## Verification checklist
|
|
31
|
+
|
|
32
|
+
- Is the session cookie secure/httpOnly/sameSite in production?
|
|
33
|
+
- Does express.static serve dotfiles?
|
|
34
|
+
|
|
35
|
+
## Fixes
|
|
36
|
+
|
|
37
|
+
Use helmet, set cookie flags from an environment-aware config, keep dotfiles denied.
|
|
38
|
+
|
|
39
|
+
## References
|
|
40
|
+
|
|
41
|
+
- https://expressjs.com/en/advanced/best-practice-security.html
|
|
42
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const helmet = require('helmet');
|
|
3
|
+
const session = require('express-session');
|
|
4
|
+
const app = express();
|
|
5
|
+
app.use(helmet());
|
|
6
|
+
app.use(session({ secret: process.env.S, cookie: { secure: true, httpOnly: true } }));
|
|
7
|
+
app.use(express.static('public', { dotfiles: 'deny' }));
|
|
8
|
+
app.use(express.json({ limit: '100kb' }));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const session = require('express-session');
|
|
3
|
+
const app = express(); // EXPECT express.fingerprint-header-enabled
|
|
4
|
+
app.use(session({ secret: process.env.S, cookie: { secure: false } })); // EXPECT express.session-cookie-insecure
|
|
5
|
+
app.use(express.static('public', { dotfiles: 'allow' })); // EXPECT express.static-dotfiles-allowed
|
|
6
|
+
app.use(express.json({ limit: '500mb' })); // EXPECT express.body-limit-huge
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "express.session-cookie-insecure",
|
|
5
|
+
"title": "Express session cookie without the secure flag",
|
|
6
|
+
"severity": "MEDIUM",
|
|
7
|
+
"cwe": [
|
|
8
|
+
614
|
|
9
|
+
],
|
|
10
|
+
"category": "session",
|
|
11
|
+
"why": "session({ cookie: { secure: false } }) sends the session cookie over plain HTTP.",
|
|
12
|
+
"fix": "Set cookie.secure to true in production (behind a proxy, also set trust proxy).",
|
|
13
|
+
"match": {
|
|
14
|
+
"kind": "call",
|
|
15
|
+
"callee": "^(?:\\w+\\.)?session$",
|
|
16
|
+
"where": [
|
|
17
|
+
{
|
|
18
|
+
"op": "callTextMatches",
|
|
19
|
+
"regex": "cookie\\s*:\\s*\\{[^}]*secure\\s*:\\s*false"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"families": [
|
|
24
|
+
"js"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "express.static-dotfiles-allowed",
|
|
29
|
+
"title": "express.static serves dotfiles",
|
|
30
|
+
"severity": "MEDIUM",
|
|
31
|
+
"cwe": [
|
|
32
|
+
538
|
|
33
|
+
],
|
|
34
|
+
"category": "config",
|
|
35
|
+
"why": "dotfiles: \"allow\" exposes .env, .git and similar files.",
|
|
36
|
+
"fix": "Use dotfiles: \"ignore\" or \"deny\".",
|
|
37
|
+
"match": {
|
|
38
|
+
"kind": "call",
|
|
39
|
+
"callee": "^express\\.static$",
|
|
40
|
+
"where": [
|
|
41
|
+
{
|
|
42
|
+
"op": "callTextMatches",
|
|
43
|
+
"regex": "dotfiles\\s*:\\s*[\\'\"]allow[\\'\"]"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"families": [
|
|
48
|
+
"js"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "express.fingerprint-header-enabled",
|
|
53
|
+
"title": "Express fingerprint header not disabled",
|
|
54
|
+
"severity": "LOW",
|
|
55
|
+
"cwe": [
|
|
56
|
+
200
|
|
57
|
+
],
|
|
58
|
+
"category": "config",
|
|
59
|
+
"why": "The X-Powered-By header tells attackers which framework to target.",
|
|
60
|
+
"fix": "Use helmet() or app.disable(\"x-powered-by\").",
|
|
61
|
+
"match": {
|
|
62
|
+
"kind": "line",
|
|
63
|
+
"line": "^\\s*(?:const|let|var)\\s+app\\s*=\\s*express\\(\\)",
|
|
64
|
+
"where": [
|
|
65
|
+
{
|
|
66
|
+
"op": "fileTextNotMatches",
|
|
67
|
+
"regex": "helmet|x-powered-by"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"families": [
|
|
72
|
+
"js"
|
|
73
|
+
],
|
|
74
|
+
"confidence": "low"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": "express.body-limit-huge",
|
|
78
|
+
"title": "Very large request body limit",
|
|
79
|
+
"severity": "LOW",
|
|
80
|
+
"cwe": [
|
|
81
|
+
770
|
|
82
|
+
],
|
|
83
|
+
"category": "dos",
|
|
84
|
+
"why": "A large JSON/urlencoded limit lets one request exhaust memory.",
|
|
85
|
+
"fix": "Keep limits small (the default 100kb) and raise only for routes that need it.",
|
|
86
|
+
"match": {
|
|
87
|
+
"kind": "call",
|
|
88
|
+
"callee": "^express\\.(?:json|urlencoded)$",
|
|
89
|
+
"where": [
|
|
90
|
+
{
|
|
91
|
+
"op": "callTextMatches",
|
|
92
|
+
"regex": "limit\\s*:\\s*[\\'\"]?(?:\\d+\\s*gb|\\d{3,}\\s*mb)"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"families": [
|
|
97
|
+
"js"
|
|
98
|
+
],
|
|
99
|
+
"confidence": "medium"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|