fix: prevent local node from self-flagging security warnings#2407
fix: prevent local node from self-flagging security warnings#2407
Conversation
… quality bouncing Three issues where the locally connected node could incorrectly target itself: 1. NO_CHANNEL and PKI error handlers could flag the local node with keyMismatchDetected — added localNodeId guards to all four error paths 2. Link quality updates processed echoed packets from the local node, causing the score to bounce between 8 and 10 — skip local node in updateLinkQualityForMessage 3. Startup cleanup: processMyNodeInfo now clears any stale security flags on the local node when it connects Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job Code Review CompleteTodo List:
Review SummaryThis PR addresses three important issues where the local node could incorrectly target itself in automated operations. The implementation is well-designed and appears correct. Code Quality & Best Practices ✅Strengths:
Security Analysis ✅No security concerns identified:
Performance Considerations ✅Minimal performance impact:
Implementation Analysis ✅Fix 1: Security Flag Self-Targeting// Before: Could flag local node
if (isPkiError(errorReason) && fromNodeId === localNodeId) {
// After: Excludes local node
if (isPkiError(errorReason) && fromNodeId === localNodeId && toNodeId !== localNodeId) {✅ Correct: Guards added to all 4 error paths ( Fix 2: Link Quality Bouncing// Before: Processed all messages including local echoes
this.updateLinkQualityForMessage(fromNum, messageHops);
// After: Skips local node
if (!this.localNodeInfo || fromNum !== this.localNodeInfo.nodeNum) {
this.updateLinkQualityForMessage(fromNum, messageHops);
}✅ Logical: Local node echoes aren't meaningful for link quality measurement Fix 3: Startup Cleanup// Clear any erroneous security flags on the local node
if (existingNode?.keyMismatchDetected || existingNode?.keySecurityIssueDetails) {
// Reset flags and emit update
}✅ Defensive: Cleans up any stale flags that may exist from before these guards Potential Issues & SuggestionsMinor: Error Message ConsistencyThe error descriptions could be more consistent:
Suggestion: Consider standardizing the tone and technical level across error messages. Test Coverage Gap
|
Summary
Three issues where the locally connected node could incorrectly target itself in automated operations:
1. Security flag self-targeting
NO_CHANNEL and PKI error handlers could flag the local node with
keyMismatchDetected, showing a spurious "Possible key or channel mismatch" warning on the local node. AddedtoNodeId !== localNodeId/targetNodeId !== localNodeIdguards to all four error paths.2. Link quality bouncing
updateLinkQualityForMessageprocessed echoed packets from the local node, causing its link quality score to bounce between 8 and 10. Now skips the local node since our own echoed packets aren't meaningful for link quality.3. Startup cleanup
processMyNodeInfonow clears any stalekeyMismatchDetected/keySecurityIssueDetailsflags on the local node when it connects, cleaning up any flags that were erroneously set before these guards were in place.Full audit results
All 10 automated systems verified for local-node exclusion — see PR description for details.
Changes
src/server/meshtasticManager.tsTest plan
npx vitest run— 3070 tests passnpm run build— no TypeScript errors🤖 Generated with Claude Code