fix(security): integrate TOFU key revocation and rotation into attestation flow#329
fix(security): integrate TOFU key revocation and rotation into attestation flow#329dannamax wants to merge 2 commits intoScottcjn:mainfrom
Conversation
|
Hey @dannamax — great improvement from v1! The inline pattern and
Fix those three and this is ready to merge. Nice work on the revision! |
|
Thanks for the feedback! I've addressed all three issues:
All changes are in the latest commit. Ready for review! |
whynice724-cell
left a comment
There was a problem hiding this comment.
Code Review: TOFU Key Revocation
Overall
Solid implementation of TOFU key management! Good approach storing first-time pubkeys and validating subsequent attestations.
Suggestions
-
Security: Consider adding rate limiting on key rotation to prevent abuse
-
Testing: Would be good to test edge cases:
- What happens if all keys are revoked?
- Recovery mechanism if TOFU store gets corrupted
-
Documentation: Add comments explaining the TOFU trust model to the README
Minor
- Consider logging key rotation events for audit purposes
Approve - ready to merge.
…ation flow - Add inline TOFU key management functions directly in rustchain_v2_integrated_v2.2.1_rip200.py - Preserve existing pyproject.toml configuration, only add pynacl dependency - Integrate TOFU validation into submit_attestation() function - Store first-time pubkeys (TOFU) and validate subsequent attestations - Support key revocation and rotation with proper audit logging - Add comprehensive integration tests for TOFU functionality - Follow PR Scottcjn#327 pattern: inline implementation, no separate modules Fixes Scottcjn#308
1dbbb3b to
54c849c
Compare
liu971227-sys
left a comment
There was a problem hiding this comment.
Security review with blocking findings:
-
TOFU check can be bypassed by omitting
pubkey.- In
node/rustchain_v2_integrated_v2.2.1_rip200.py:2011, validation only runs underif pubkey and miner:. - For a miner with an already pinned key, sending no
pubkeyskips TOFU enforcement entirely and continues the attestation flow. - This defeats key pinning for any client that omits the field.
- In
-
signatureis parsed but never cryptographically verified.signature = data.get(signature)is read around line 1992, but no Ed25519 verify call is performed before accepting attestation.- Current logic only compares submitted
pubkeystring to stored key (tofu_validate_key), which does not prove possession of the private key. - An attacker who knows the public key can still pass validation by reusing that pubkey.
-
Dependency declaration is in the wrong section.
pyproject.toml:18addsdependencies = [pynacl, ...]under[tool.mypy]context, so package installers will not treat it as runtime dependency.- If signature verification is required, dependency must be declared in the project/dependency section actually used by build/install.
Suggested fix direction:
- Enforce: if miner has existing pinned key, missing
pubkeyor missingsignature=> reject. - Verify Ed25519 signature over a canonical message (nonce/challenge/report fields) before accepting attestation.
- Add negative tests for omitted pubkey/signature and forged signature.
- Move dependency declaration to the correct package metadata section.
This PR implements TOFU (Trust On First Use) Key Revocation and Rotation functionality as requested in issue #308.
Changes
Testing
Fixes #308
Bounty: 15 RTC