serviceability: restrict device tunnel block to private/link-local#3833
Merged
Conversation
martinsander00
approved these changes
Jun 4, 2026
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.
Resolves: #3832
Summary of Changes
device_tunnel_blockis a private (RFC1918) or link-local (RFC3927) prefix when set onchain, matching the restriction already applied to device interface IPs.DoubleZeroError::InvalidDeviceTunnelBlock(custom code 88) instead of silently accepting it.user_tunnel_block,multicastgroup_block,multicast_publisher_block) are intentionally left unchanged.Diff Breakdown
Small, focused enforcement change; the bulk of the line count is the new acceptance test.
Key files (click to expand)
smartcontract/programs/doublezero-serviceability/tests/globalconfig_test.rs— new acceptance test: public block rejected withCustom(88); private and link-local blocks accepted.smartcontract/programs/doublezero-serviceability/src/helper.rs— addsis_private_or_link_local()helper plus unit test covering RFC1918/RFC3927 vs public/CGNAT/multicast/unspecified.smartcontract/programs/doublezero-serviceability/src/processors/globalconfig/set.rs— validatesdevice_tunnel_blockinprocess_set_globalconfigbefore writing state; un-gates themsg!import.smartcontract/programs/doublezero-serviceability/src/error.rs— adds theInvalidDeviceTunnelBlockvariant and itsFrommappings.Testing Verification
globalconfig_test.rsasserts a publicdevice_tunnel_block(8.8.8.0/24) fails withInvalidDeviceTunnelBlock, while10.100.0.0/24(private) and169.254.0.0/24(link-local) succeed.is_private_or_link_localcovers the allowed and rejected ranges.-Dclippy::all -Dwarnings) pass.