Repository navigation
fix(dashmate): restrict a gateway TLS private key an older version left readable - #5654
Conversation
…ft readable Older dashmate versions created the gateway's private.key at the process umask, so upgraded nodes can carry a group- and world-readable key. Two historical config migrations copy the key to a new directory and kept that mode. The migrations now restrict the copied key to 0600, starting a node drops the group and other bits of an existing key, keeping an owner's stricter mode, and `dashmate doctor` reports a key other users can read. Starting only warns when the key cannot be restricted, for example when root owns it, so an upgrade cannot keep a masternode from starting. Windows reports a writable file as 0666 whatever its ACL allows, so doctor collects the mode only on POSIX hosts. A descriptor opened while the key was readable can still read a renewed key, because a renewal rewrites the same inode; that needs a change to how the gateway mounts the key, tracked in #5506. Moved out of #4283, where it was written test-first and reviewed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
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. Comment |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
@coderabbitai review |
|
|
⛔ Final review complete — 1 blocking finding(s) (commit 156409e) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The POSIX permission hardening is effective, and the dashmate tests pass. However, the same change does not secure legacy keys on supported Windows hosts: Node's chmod implementation does not replace NTFS ACLs, while doctor intentionally skips Windows permission checks, leaving broad ACL access undetected. The dashmate lint check and helper-image build were still pending in the supplied CI snapshot.
🔴 1 blocking
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff changes gateway TLS private-key handling in start, migration, certificate-renewal, and diagnostic paths, directly affecting protection of cryptographic key material. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/dashmate/src/listr/tasks/startNodeTaskFactory.js`:
- [BLOCKING] packages/dashmate/src/listr/tasks/startNodeTaskFactory.js:100-105: Windows startup hardening does not restrict ACL-readable private keys
On Windows, `fs.chmodSync(privateKeyFilePath, ... )` changes the file's read-only attribute but does not remove inherited or explicit NTFS ACL entries granting other local users read access. Therefore, a legacy `private.key` that is readable through a broad ACL remains exposed after `dashmate start`; the equivalent `chmodSync` calls in both migration paths have the same limitation. The new doctor collection also skips Windows entirely at `collectSamplesTaskFactory.js:156`, so it cannot report this condition. Because Windows is a supported dashmate platform, another local user may still copy the gateway TLS key and impersonate the gateway or perform a TLS MITM without warning. Apply a Windows ACL restriction for the intended account and verify effective access, or explicitly exclude Windows from the security guarantee and provide an appropriate diagnostic.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Open gateway key descriptors can outlive permission tightening — A gateway process that already opened the old readable inode can retain access when renewal rewrites that inode, even after the new mode is applied. This behavior predates the reviewed range and is already tracked by #5506.
- Follow-up: Continue #5506 by mounting the gateway SSL directory instead of the individual key file, then test renewal with an already-open descriptor.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
chmod does not change the NTFS ACLs that decide who can read a file on Windows, so restricting the key on start protects POSIX hosts only. Comment change only; no behaviour change, so no new test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
The Windows ACL finding is answered in its thread. This pull request fixes the POSIX mode that older dashmate versions left on the key, and is scoped to POSIX hosts, as the startup comment (156409e) and the description now state. On Windows the chmod calls are no-ops; restricting NTFS ACLs is separate work.
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The reviewed commit only clarifies that the existing chmod hardening applies to POSIX hosts; it does not address Windows ACLs. Because dashmate publishes a Windows target and its installation documentation recommends Windows packages for mainnet masternodes, legacy gateway keys can still be readable by other local users there, leaving the security fix incomplete. Dashmate lint and unit tests for this head were still queued in the supplied CI snapshot.
🔴 1 blocking
1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff changes gateway TLS private-key permission handling across migrations, node startup, certificate renewal, and diagnostics, directly affecting secret/key protection on a security-critical surface. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/dashmate/src/listr/tasks/startNodeTaskFactory.js`:
- [BLOCKING] packages/dashmate/src/listr/tasks/startNodeTaskFactory.js:92: Windows startup hardening does not restrict ACL-readable private keys
(existing thread: https://github.com/dashpay/platform/pull/5654#discussion_r4412615182)
The comment accurately states that `chmod` does not change Windows ACLs, but the startup path still provides no restriction for a legacy key with inherited or explicit NTFS read access granted to other local users. The two migration copies likewise call only `chmod`, and `collectSamplesTaskFactory` skips Windows because its mode is not meaningful there, so `dashmate doctor` cannot detect this exposure. Dashmate publishes `win32-x64`, and the installation guide recommends Windows packages for mainnet masternodes; therefore this remains a security gap on a supported target. Implement Windows ACL restriction and effective-access diagnostics, or add a tracked Windows-specific follow-up and explicitly narrow the supported security guarantee. The referenced #5506 follow-up covers renewed-key inode mounts, not Windows ACLs.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix. |
Issue being fixed or feature implemented
Older dashmate versions created the gateway's TLS private key (
<home>/<config>/platform/gateway/ssl/private.key) at the process umask, so upgraded nodes can carry a group- and world-readable key. Two historical config migrations copy the key to a new directory and kept that mode.Split out of #4283, where it was reviewed.
What was done?
0600.0400. If the key cannot be restricted, for example because root owns it after asudorun, starting only warns: an upgrade must not keep a masternode from starting.dashmate doctorreports a key that other users can read. Windows reports a writable file as0666whatever its ACL allows, so the mode is collected only on POSIX hosts.This covers POSIX hosts, where the umask problem exists. On Windows, file access lives in NTFS ACLs, which
chmoddoes not change; restricting those is separate work.Follow-up
#5506: a descriptor opened while the key was readable can still read a renewed key, because a renewal rewrites the same inode. Fixing that needs the gateway to mount the
ssldirectory instead of the key file.How Has This Been Tested?
Tests:
startNodeTaskFactory.spec.js: restricts a world-readable key, keeps a restricted or stricter key, creates no key, warns and starts whenchmodfails;migrateConfigFileFactory.spec.js: both copying migrations restrict the key;collectSamplesTaskFactory.spec.jsandanalyseConfigFactory.spec.js: the doctor sample and its verdict, including Windows;saveCertificateTask.spec.js: an exposed key is restricted before it is rewritten.The tests were written failing first in fix(dashmate): keep the node up when an image pull fails, and stop reporting success when it did not #4283.
The whole dashmate unit suite on this branch: 965 passing.
Not run: a live gateway. That the container can still read the tightened key rests on the compose wiring, where
ENVOY_UIDis the operator's own uid.Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
156409e/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.