Skip to content

MF-M05: fix(nitronode): enforce TLS by default for Postgres#733

Merged
philanton merged 2 commits into
fix/audit-findings-finalfrom
fix/nitronode-mf-m05
May 12, 2026
Merged

MF-M05: fix(nitronode): enforce TLS by default for Postgres#733
philanton merged 2 commits into
fix/audit-findings-finalfrom
fix/nitronode-mf-m05

Conversation

@philanton
Copy link
Copy Markdown
Contributor

@philanton philanton commented May 8, 2026

Summary

  • Replace hardcoded sslmode=disable in postgresqlDbUrl with configurable NITRONODE_DATABASE_SSLMODE (binary default: require, validated against the libpq list).
  • Honor NITRONODE_DATABASE_URL verbatim when set so operators can supply a fully-qualified DSN; individual host/user/password/sslmode fields are ignored in that case.
  • Wire helm chart helper to propagate config.database.sslmode as NITRONODE_DATABASE_SSLMODE. Chart default is require so helm and the binary agree; deployments where Postgres is only reachable on a private network (e.g. cluster-internal pgbouncer, VPC-only Cloud SQL) can opt out by setting sslmode: disable. The stress-v1 profile does so explicitly.

Why

Audit finding MF-M05: every Postgres connection (schema create, migrations, runtime) used sslmode=disable, so credentials and protocol traffic could be observed or tampered with by anyone on the path. The chart documented an sslmode value but never propagated it.

Notes

  • Binary default is require (TLS without cert verification). Operators wanting strict cert checking should set verify-full.
  • Local dev / testcontainers paths still use sslmode=disable intentionally.
  • Release note: direct binary users without TLS-capable Postgres must set NITRONODE_DATABASE_SSLMODE=disable explicitly. Helm users on a private-network Postgres must set config.database.sslmode: disable to keep the previous behavior.

Test plan

  • go test ./nitronode/store/database/ -run TestPostgresqlDbUrl — covers default, explicit, invalid, schema append, URL precedence, unsupported driver
  • go vet ./nitronode/store/database/ clean
  • go build ./nitronode/... clean
  • Helm template renders correctly with sslmode set / unset (default → require, override → disable)
  • Manual smoke against TLS-enabled Postgres

🤖 Generated with Claude Code

Replace the hardcoded `sslmode=disable` in postgresqlDbUrl with a
configurable NITRONODE_DATABASE_SSLMODE (default `require`), validate
the mode against the libpq list, and honor NITRONODE_DATABASE_URL
verbatim when set so operators can supply a fully-qualified DSN.

Wire the helm chart to propagate `config.database.sslmode` through
NITRONODE_DATABASE_SSLMODE; chart default stays `disable` to avoid
breaking existing deployments — operators must opt-in to TLS via
values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 98e2a674-f208-403f-83c2-b2417b460797

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/nitronode-mf-m05

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread nitronode/chart/templates/helpers/_common.tpl Outdated
Copy link
Copy Markdown
Contributor

@nksazonov nksazonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Go-layer fix is solid: the SSLMode field, URL-override path, validation map, and tests are all correct. One gap remains on the chart side — the template default in _common.tpl still ships disable, which means TLS is opt-in rather than opt-out for any deployment that doesn't explicitly set the value. Everything else looks good.

@philanton philanton changed the base branch from main to fix/audit-findings-final May 8, 2026 15:55
Flip the helm chart's `config.database.sslmode` default from `disable` to
`require` so deployments that expose Postgres over an untrusted network
get TLS without extra configuration, matching the binary default.

Setups where Postgres is only reachable on a private network (e.g. an
in-cluster pgbouncer or VPC-only Cloud SQL) can opt out by setting
`sslmode: disable`. The stress-v1 profile does so explicitly, since its
pgbouncer is cluster-internal.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@ihsraham ihsraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved for m-05 closure. the postgres path now defaults to tls in both the binary and helm, with explicit opt-out documented for private-network setups.

@philanton philanton merged commit 769bd79 into fix/audit-findings-final May 12, 2026
3 checks passed
@philanton philanton deleted the fix/nitronode-mf-m05 branch May 12, 2026 08:51
nksazonov pushed a commit that referenced this pull request May 13, 2026
- MF-L01: fix(contracts/ChannelHub): cap ERC20 transfer returndata copy to 32 bytes (#726)                                                
- MF-H01: fix(nitronode): paginate get_last_key_states endpoints (#724)                                                                   
- MF-I01-I02: fix(contracts): address security audit findings I-01 and I-02 (#728)                                                        
- MF-C01: rpc: cap inbound WebSocket frame size and rate-limit per connection (#723)                                                      
- MF-L02: docs(protocol): qualify enforcement guarantee for intent-specific execution paths (#737)                                        
- MF-L02-I03-I04_I05: fix(contracts): add more Node trust assumptions and requirements (#738)                                             
- MF-M01: backfill state user_sig from on-chain events (#731)               
- MF-M02: fix(rpc): release Serve wait group on processSink overflow (#732)                                                               
- Fix SDK acknowledgement before home channel creation (#734)               
- MF-I06: fix(nitronode): gate escrow transitions on home channel onchain materialization (#730)                                          
- MF-M05: fix(nitronode): enforce TLS by default for Postgres (#733)                                                                      
- MF-M07: Unblock receiver states after finalized escrow operations (#735)
- MF-M04: feat: provide tooling for and enhance docs on ValidatorRegistered event (#744)                                                  
- MF-L04: fix(contracts): reject redundant native value (#741)              
- MF-H02: bind session key registration to a single owner per kind (#739)                                                                 
- MF-I07: fix(contracts): enforce max challenge duration (#752)             
- MF-M08: fix(rpc): replace Origin label with application_id on connection gauge (#745)                                                   
- MF-C02: fix(core): add ChannelStatusClosing to gate post-finalize state transitions (#746)                                              
- MF-L06: fix(contracts): clear stale challengeExpireAt on cooperative escrow finalization (#754)
- MF-I08: docs: document ChannelClosed event orientation ambiguity during abandoned migration (#755)                                      
- MF-M09: fix(nitronode): auto-challenge home channel on withheld escrow finalize (#753)
- MF-L09: fix(nitronode): validate parsed app session nonce (#751)                                                                        
- MF-L05: docs(contracts): document informational events not guaranteed to emit (#756)
- MF-L08: fix(nitronode/api): default get_last_key_states to active-only with include_inactive opt-in (#749)                              
- MF-L10: fix: emit escrowIds array in EscrowDepositsPurged event and handle it in Nitronode (#757)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants