Add security validation and RFC compliance fixes#277
Merged
Conversation
Security fixes: - AS_PATH segment count validation to prevent buffer over-read - BGP message length underflow protection with saturating arithmetic - NLRI prefix length validation (max 32 for IPv4, 128 for IPv6) - BGP marker encoding fix per RFC 4271 (16 bytes of 0xFF) - BGP marker validation on parse with warning for invalid markers - Attribute length overflow protection Stability fixes: - Communities divisibility validation (4/8/12 bytes) - FlowSpec traffic rate NaN/infinity validation - FlowSpec DSCP byte offset correction per RFC 5575 - Replace assert_eq! with debug_assert_eq! in production code - Timestamp truncation fix for values beyond 2106 - Remove unwrap() in favor of proper error handling - Encoding truncation checks with overflow warnings - Reject IPv6 for AGGREGATOR and ORIGINATOR_ID attributes RFC compliance: - RFC 7606 error handling (PARTIAL flag, treat-as-withdraw) - RFC 4760 NEXT_HOP/MP_REACH_NLRI interaction - Document NLRI parsing heuristics Tests: Add 18 new tests covering security vulnerabilities
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #277 +/- ##
==========================================
- Coverage 90.59% 90.48% -0.11%
==========================================
Files 84 84
Lines 15592 15729 +137
==========================================
+ Hits 14125 14233 +108
- Misses 1467 1496 +29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses security vulnerabilities and RFC compliance issues identified in security audits.
Security Fixes
Critical
Stability
RFC Compliance
Testing
References
Addresses findings from security audits of bgpkit-parser.
Backward Compatibility
All changes maintain backward compatibility. Stricter validation may reject previously-accepted malformed data, which is the intended security improvement.