Nginx hardening + infra updates#87
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThis PR adds a new SSH key entry for ChangesSSH Key and Role Addition
Nginx Security Hardening
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 3 seconds.Comment |
7d30c9b to
7d1d763
Compare
How to use the Graphite Merge QueueAdd the label add-to-gt-merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
fb31e7b to
56061d9
Compare
7d1d763 to
b14e075
Compare
findolor
left a comment
There was a problem hiding this comment.
This review is given by Graphite
Critical Issues:
sandbox = false(line 169) - This disables Nix build isolation, which is a security reduction. The PR description doesn't explain why this is needed. This should be justified or removed.- Host SSH key change (line 6) - The host SSH key is completely changed, but this isn't mentioned in the PR description. This could break existing SSH connections and needs verification that it's intentional.
- Volume device path change (line 160) - Changing from
st0x-rest-api-datatost0x-rest-api-data-v2is a critical infrastructure change. If the new volume doesn't exist or isn't properly migrated, the system won't boot. This needs confirmation that the volume is ready.
Potential Issues:
- Rate limiting - 10r/s might be too restrictive for legitimate API usage patterns. Consider if burst=20 is sufficient for typical workflows.
client_max_body_size 1m(line 121) - Verify that all API endpoints can work with max 1MB request bodies.- Exploit blocking patterns (lines 125-131) - The regex
~ \\.(php|asp|aspx|jsp|cgi)$might have edge cases. Also returning 444 provides no feedback to clients.
56061d9 to
b63a8ef
Compare
b14e075 to
4cd0e5a
Compare
4cd0e5a to
e92b5a1
Compare
b63a8ef to
5fafb1f
Compare
e92b5a1 to
b8ca651
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
keys.nix (1)
17-18: Existing.agefiles must be re-encrypted after this merge —alastaircannot decrypt them until that happens.Age/rage encryption is fixed at the time the file is encrypted. The current
terraform.tfstate.ageandterraform.tfvars.agewere sealed with the old recipient list (noalastair). Adding the key tokeys.nixonly affects future invocations ofencryptState/encryptVarsininfra/default.nix. Until those functions are re-run and the.agefiles are committed with the new ciphertext,alastairwill not be able to decrypt either secrets file — despite appearing in both roles.Action required: after merging, run
encryptStateandencryptVars(or the equivalentnixtask), commit the updated.agefiles, and verify decryption succeeds withalastair's key.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@keys.nix` around lines 17 - 18, The .age files were encrypted before adding alastair to keys.nix, so re-encrypt the existing secrets with the new recipient list: open infra/default.nix and run encryptState and encryptVars (or the project’s equivalent nix task) to regenerate terraform.tfstate.age and terraform.tfvars.age, commit the updated .age files, and verify decryption using alastair’s key to confirm they can now decrypt; note that merely adding alastair to keys.nix does not retroactively re-encrypt existing files.os.nix (1)
102-103: ⚡ Quick winConsider BREACH exposure when
recommendedGzipSettingsis combined with HTTPS.An application is vulnerable to BREACH when all three conditions are present simultaneously: HTTP compression is enabled, user input is reflected in responses, and secrets appear in the response body. Since this is a public REST API over HTTPS, if any endpoint returns compressed responses that mix user-controlled content with sensitive values (tokens, API keys, etc.), BREACH applies.
If any such endpoints exist, a targeted mitigation is straightforward:
🛡️ Suggested per-location opt-out
locations."/" = { proxyPass = "http://127.0.0.1:8000"; extraConfig = '' + # Disable gzip on endpoints that return secrets alongside user input (BREACH) + gzip off; limit_req zone=api burst=20 nodelay; limit_req_status 429; ''; };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@os.nix` around lines 102 - 103, The current config enables HTTP compression via the recommendedGzipSettings variable which, when combined with HTTPS and reflected user input, can create a BREACH risk; either disable compression globally by setting recommendedGzipSettings = false or implement a per-endpoint opt-out so responses that may include secrets skip gzip—add a per-route flag (e.g., recommendedGzipSettingsPerLocation or compress: false) and ensure server middleware (the gzip/compression handler) checks that flag before compressing responses that reflect user input or include secrets.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@os.nix`:
- Around line 125-130: Change the two location keys that use the case-sensitive
regex operator "~" to use the case-insensitive operator "~*" so that
locations."~ \\\\.(php|asp|aspx|jsp|cgi)$" becomes locations."~*
\\\\.(php|asp|aspx|jsp|cgi)$" and locations."~
^/(containers|_ignition|vendor|public/index)" becomes locations."~*
^/(containers|_ignition|vendor|public/index)"; update both location keys
accordingly.
---
Nitpick comments:
In `@keys.nix`:
- Around line 17-18: The .age files were encrypted before adding alastair to
keys.nix, so re-encrypt the existing secrets with the new recipient list: open
infra/default.nix and run encryptState and encryptVars (or the project’s
equivalent nix task) to regenerate terraform.tfstate.age and
terraform.tfvars.age, commit the updated .age files, and verify decryption using
alastair’s key to confirm they can now decrypt; note that merely adding alastair
to keys.nix does not retroactively re-encrypt existing files.
In `@os.nix`:
- Around line 102-103: The current config enables HTTP compression via the
recommendedGzipSettings variable which, when combined with HTTPS and reflected
user input, can create a BREACH risk; either disable compression globally by
setting recommendedGzipSettings = false or implement a per-endpoint opt-out so
responses that may include secrets skip gzip—add a per-route flag (e.g.,
recommendedGzipSettingsPerLocation or compress: false) and ensure server
middleware (the gzip/compression handler) checks that flag before compressing
responses that reflect user input or include secrets.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
b8ca651 to
2db92e9
Compare

Summary
client_max_body_size 1mfor API payloadsTest plan
cargo checkpassesrainix-rs-staticpassesSummary by CodeRabbit
New Features
Chores