Skip to content

Commit 6dbd577

Browse files
authored
improve baseline HTTP security for no-reverse proxy deployment scenarios (#282)
* add baseline security headers * only set HSTS header in HTTPS mode * set request body size limit * add request timeout * enable rate limiting by default * set cookie control header for api routes * adjust cookie security settings * review fixes * reorder http server layers * simplify middleware * mirror default rate limit in example config file * update deps * remove override * install trivy in nix shell * setup trivyignore * fix action tag
1 parent b278172 commit 6dbd577

15 files changed

Lines changed: 575 additions & 395 deletions

.github/workflows/build-docker.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ jobs:
7070

7171
- name: Scan image with Trivy
7272
uses: aquasecurity/trivy-action@v0.36.0
73+
env:
74+
TRIVY_SHOW_SUPPRESSED: 1
75+
TRIVY_IGNOREFILE: "./.trivyignore.yaml"
7376
with:
7477
image-ref: "${{ env.GHCR_REPO }}:${{ github.sha }}-${{ matrix.tag }}"
7578
format: "table"

.github/workflows/sbom.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434

3535
- name: Create SBOM with Trivy
3636
uses: aquasecurity/trivy-action@v0.36.0
37+
env:
38+
TRIVY_SHOW_SUPPRESSED: 1
39+
TRIVY_IGNOREFILE: "./.trivyignore.yaml"
3740
with:
3841
scan-type: 'fs'
3942
format: 'spdx-json'
@@ -44,6 +47,9 @@ jobs:
4447

4548
- name: Create Docker image SBOM with Trivy
4649
uses: aquasecurity/trivy-action@v0.36.0
50+
env:
51+
TRIVY_SHOW_SUPPRESSED: 1
52+
TRIVY_IGNOREFILE: "./.trivyignore.yaml"
4753
with:
4854
image-ref: "ghcr.io/defguard/defguard-proxy:${{ steps.vars.outputs.VERSION }}"
4955
scan-type: 'image'
@@ -54,6 +60,9 @@ jobs:
5460

5561
- name: Create security advisory file with Trivy
5662
uses: aquasecurity/trivy-action@v0.36.0
63+
env:
64+
TRIVY_SHOW_SUPPRESSED: 1
65+
TRIVY_IGNOREFILE: "./.trivyignore.yaml"
5766
with:
5867
scan-type: 'fs'
5968
format: 'json'
@@ -64,6 +73,9 @@ jobs:
6473

6574
- name: Create Docker image security advisory file with Trivy
6675
uses: aquasecurity/trivy-action@v0.36.0
76+
env:
77+
TRIVY_SHOW_SUPPRESSED: 1
78+
TRIVY_IGNOREFILE: "./.trivyignore.yaml"
6779
with:
6880
image-ref: "ghcr.io/defguard/defguard-proxy:${{ steps.vars.outputs.VERSION }}"
6981
scan-type: 'image'

.trivyignore.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
vulnerabilities:
22
- id: GHSA-w5hq-g745-h8pq
3-
expired_at: 2026-04-30
4-
statement: 'Not yet fixed in dependencies'
3+
expired_at: 2026-05-23
4+
statement: "Waiting for upstream patch in paraglide"

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ axum-server = { version = "0.8", features = ["tls-rustls"] }
2525
time = { version = "0.3", default-features = false }
2626
tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync", "time"] }
2727
tokio-stream = "0.1"
28-
tower-http = { version = "0.6", features = ["fs", "trace"] }
28+
tower-http = { version = "0.6", features = ["fs", "trace", "timeout"] }
2929
# logging/tracing
3030
tracing = "0.1"
3131
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

example-config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ http_port = 8080
77
grpc_port = 50051
88

99
log_level = "info"
10-
rate_limit_per_second = 0
11-
rate_limit_burst = 0
10+
rate_limit_per_second = 10
11+
rate_limit_burst = 100
1212
acme_staging = false

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
buf
4141
# image signarute verification
4242
cosign
43+
trivy
4344
];
4445

4546
# Specify the rust-src path (many editors rely on this)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"devDependencies": {
3-
"@tanstack/devtools-vite": "^0.3.11"
3+
"@tanstack/devtools-vite": "^0.3.12"
44
}
55
}

0 commit comments

Comments
 (0)