Skip to content

Commit 6232b50

Browse files
r2c-argo[bot]reedlodeninkzSjord
authored
Merge Develop into Release (#3594)
* Improve `insecure-load-balancer-tls-version` AWS rule (#3584) Add support for `ELBSecurityPolicy-TLS13-1-2-Res-2021-06`, which is the most secure TLS 1.2+ policy that AWS ALBs offer. Recommend it as the preferred fix for rule failures. `ELBSecurityPolicy-TLS13-1-2-Res-2021-06` removes the following (insecure) cipher suites as compared to `ELBSecurityPolicy-TLS13-1-2-2021-06` because they are CBC-based instead of GCM-based: - ECDHE-ECDSA-AES128-SHA256 - ECDHE-RSA-AES128-SHA256 - ECDHE-ECDSA-AES256-SHA384 - ECDHE-RSA-AES256-SHA384 https://docs.aws.amazon.com/elasticloadbalancing/latest/application/describe-ssl-policies.html#tls-security-policies Also, improve/clean-up related test. Co-authored-by: Vasilii Ermilov <[email protected]> * Add subprocess-list-passed-as-string for Python (#3579) * Add subprocess-list-passed-as-string for Python subprocess.run and similar takes either a string or a sequence. Some calling code has a sequence, but converts it to string themselves. This is both unnecessary and insecure, as it removes the distinction between arguments. I.e. if arguments contain spaces or quotes this gives the wrong result. * Update subprocess-list-passed-as-string.yaml * Rename python/lang/security/subprocess-list-passed-as-string.py to python/lang/security/audit/subprocess-list-passed-as-string.py * Rename python/lang/security/subprocess-list-passed-as-string.yaml to python/lang/security/audit/subprocess-list-passed-as-string.yaml --------- Co-authored-by: Vasilii Ermilov <[email protected]> Co-authored-by: Vasilii Ermilov <[email protected]> * bump Ubuntu version in Github actions (#3593) * bump Ubuntu version in Github actions * bump setup-python version * bump python versions in Github actions * bump python versions in Github actions --------- Co-authored-by: Reed Loden <[email protected]> Co-authored-by: Vasilii Ermilov <[email protected]> Co-authored-by: Sjoerd Langkemper <[email protected]> Co-authored-by: Vasilii Ermilov <[email protected]>
1 parent dadbe58 commit 6232b50

11 files changed

+114
-21
lines changed

.github/workflows/semgrep-rule-lints.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ on:
77

88
jobs:
99
semgrep:
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
1111
name: semgrep-rule-lints
1212
steps:
1313
- uses: actions/checkout@v2
14-
- uses: actions/setup-python@v2
14+
- uses: actions/setup-python@v5
1515
with:
16-
python-version: 3.9.2
16+
python-version: '3.10'
1717
- name: install semgrep
1818
run: pip3 install semgrep
1919
- name: lints for semgrep rules

.github/workflows/semgrep-rules-test-develop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
name: rules-test-develop
1717
# alt: use directly the semgrep/semgrep:pro-develop container here so we
1818
# don't need the calls to 'docker run ...' below
19-
runs-on: ubuntu-20.04
19+
runs-on: ubuntu-22.04
2020
# TODO: remove the with: path: below to simplify
2121
steps:
2222
- uses: actions/checkout@v2

.github/workflows/semgrep-rules-test-historical.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ on:
1111
jobs:
1212
test-historical:
1313
name: rules-test-historical
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-22.04
1515
steps:
1616
- uses: actions/checkout@v2
1717
with:
1818
path: semgrep-rules
1919
fetch-depth: 0
20-
- uses: actions/setup-python@v2
20+
- uses: actions/setup-python@v5
2121
with:
22-
python-version: 3.9.2
22+
python-version: '3.10'
2323
- name: Find merge base with develop
2424
id: merge_base
2525
run: echo "BASE_COMMIT=$(git -C semgrep-rules merge-base origin/develop HEAD)" >> $GITHUB_ENV

.github/workflows/semgrep-rules-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ on:
1111
jobs:
1212
test-latest:
1313
name: rules-test-latest
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-22.04
1515
steps:
1616
- uses: actions/checkout@v2
17-
- uses: actions/setup-python@v2
17+
- uses: actions/setup-python@v5
1818
with:
19-
python-version: 3.9.2
19+
python-version: '3.10'
2020
- name: install semgrep via pip
2121
run: pip3 install semgrep
2222
- name: remove stats directory

.github/workflows/trigger-pro-benchmark-scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
# do not run automatically if rule is posted from the playground (can still be started manually)
1212
# PRs posted by first time contributors already need approval as well
1313
if: github.actor != 'semgrep-dev-pr-bot'
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-22.04
1515
steps:
1616
- id: trigger-run
1717
name: Trigger semgrep-rules-pro benchmarking argo workflow on PR/push to develop or release

.github/workflows/trigger-semgrep-scanner-initiate-scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
# do not run automatically if rule is posted from the playground (can still be started manually)
1212
# PRs posted by first time contributors already need approval as well
1313
if: github.actor != 'semgrep-dev-pr-bot'
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-22.04
1515
steps:
1616
- uses: actions/checkout@v2
1717
with:

.github/workflows/validate-r2c-registry-metadata.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
validate-metadata:
1616
if: github.repository == 'semgrep/semgrep-rules'
1717
name: Validate r2c registry metadata
18-
runs-on: ubuntu-20.04
18+
runs-on: ubuntu-22.04
1919
steps:
2020
- uses: actions/checkout@v2
2121
with:
@@ -32,9 +32,9 @@ jobs:
3232
CHANGED_FILES: ${{ steps.changed-files.outputs.CHANGED_FILES }}
3333
name: debugging step - print changed files
3434
run: echo $CHANGED_FILES
35-
- uses: actions/setup-python@v2
35+
- uses: actions/setup-python@v5
3636
with:
37-
python-version: 3.9.2
37+
python-version: '3.10'
3838
- name: install deps
3939
run: pip install jsonschema pyyaml
4040
- name: validate metadata
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
from sys import argv
3+
import subprocess
4+
5+
# ruleid: subprocess-list-passed-as-string
6+
subprocess.run(" ".join(["snakemake", "-R", "`snakemake --list-params-changes`"] + argv[1:]), shell=True)
7+
8+
# ok: subprocess-list-passed-as-string
9+
subprocess.run(["snakemake", "-R", "`snakemake --list-params-changes`"] + argv[1:], shell=True)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
rules:
2+
- id: subprocess-list-passed-as-string
3+
languages: [python]
4+
severity: WARNING
5+
message: >-
6+
Detected `" ".join(...)` being passed to `subprocess.run`. This can lead to
7+
argument splitting issues and potential security vulnerabilities. Instead, pass
8+
the list directly to `subprocess.run` to preserve argument separation.
9+
mode: taint
10+
pattern-sources:
11+
- pattern: |
12+
" ".join($LIST)
13+
pattern-sinks:
14+
- patterns:
15+
- pattern: subprocess.run($ARGS, ...)
16+
- focus-metavariable: $ARGS
17+
- patterns:
18+
- pattern: subprocess.Popen($ARGS, ...)
19+
- focus-metavariable: $ARGS
20+
- patterns:
21+
- pattern: subprocess.call($ARGS, ...)
22+
- focus-metavariable: $ARGS
23+
- patterns:
24+
- pattern: subprocess.check_call($ARGS, ...)
25+
- focus-metavariable: $ARGS
26+
- patterns:
27+
- pattern: subprocess.check_output($ARGS, ...)
28+
- focus-metavariable: $ARGS
29+
metadata:
30+
category: security
31+
cwe: "CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')"
32+
references:
33+
- "https://docs.python.org/3/library/subprocess.html#frequently-used-arguments"
34+
owasp:
35+
- A03:2021 - Injection
36+
technology:
37+
- python
38+
confidence: LOW
39+
subcategory:
40+
- audit
41+
likelihood: LOW
42+
impact: HIGH

terraform/aws/security/insecure-load-balancer-tls-version.tf

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,48 @@ resource "aws_alb_listener" "https_fs_1_2" {
137137
}
138138
}
139139

140+
resource "aws_alb_listener" "tls_1_3_1_2" {
141+
load_balancer_arn = var.aws_lb_arn
142+
protocol = "TLS"
143+
port = "8080"
144+
# ok: insecure-load-balancer-tls-version
145+
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06"
146+
certificate_arn = var.certificate_arn
147+
148+
default_action {
149+
type = "forward"
150+
target_group_arn = var.aws_lb_target_group_arn
151+
}
152+
}
153+
154+
resource "aws_alb_listener" "tls_1_3_1_2_res" {
155+
load_balancer_arn = var.aws_lb_arn
156+
protocol = "TLS"
157+
port = "8080"
158+
# ok: insecure-load-balancer-tls-version
159+
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-Res-2021-06"
160+
certificate_arn = var.certificate_arn
161+
162+
default_action {
163+
type = "forward"
164+
target_group_arn = var.aws_lb_target_group_arn
165+
}
166+
}
167+
168+
resource "aws_alb_listener" "tls_1_3_1_3" {
169+
load_balancer_arn = var.aws_lb_arn
170+
protocol = "TLS"
171+
port = "8080"
172+
# ok: insecure-load-balancer-tls-version
173+
ssl_policy = "ELBSecurityPolicy-TLS13-1-3-2021-06"
174+
certificate_arn = var.certificate_arn
175+
176+
default_action {
177+
type = "forward"
178+
target_group_arn = var.aws_lb_target_group_arn
179+
}
180+
}
181+
140182
resource "aws_lb_target_group" "foo" {
141183
name = "foo"
142184
port = 80
@@ -207,12 +249,12 @@ resource "aws_alb_listener" "tls_fs_1_1" {
207249
}
208250
}
209251

210-
resource "aws_alb_listener" "tls_1_3" {
252+
resource "aws_alb_listener" "tls_fs_1_0" {
211253
load_balancer_arn = var.aws_lb_arn
212254
protocol = "TLS"
213255
port = "8080"
214-
# ok: insecure-load-balancer-tls-version
215-
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-068"
256+
# ruleid: insecure-load-balancer-tls-version
257+
ssl_policy = "ELBSecurityPolicy-FS-2018-06"
216258
certificate_arn = var.certificate_arn
217259

218260
default_action {

0 commit comments

Comments
 (0)