Fix MAC addresses and timestamps being guessed as IPv6 attributes - #13
Merged
Conversation
The colon-hex fallback in guess_attribute_types() matched any string made only of hex digits and colons (e.g. 'de:ad:be:ef:00:01' or a HH:MM:SS timestamp), guessing ip-src/ip-dst for values that aren't IPv6 at all. Replace the blanket character-class regex with looks_like_ipv6_fragment(), which requires real IPv6 group structure: either exactly 8 groups of 1-4 hex digits, or a single '::' compression with at most 7 groups total, each 1-4 hex digits. A 6-group, 2-hex-digit MAC address no longer matches.
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.
Finding 36 (Low) —
bin/cli.py:294-296Problem
The colon-hex fallback matches anything made only of hex digits and colons, so MAC addresses and HH:MM:SS times are guessed as ip-src/ip-dst - 'de:ad:be:ef:00:01' returns [ip-dst, ip-src].
Fix
Fixed finding #36 (mac-as-ip, low severity): the colon-hex IPv6 fallback in guess_attribute_types() (bin/cli.py) used a blanket character-class regex
^[A-Fa-f0-9:]+$that matched any hex-and-colon string, so MAC addresses (e.g. 'de:ad:be:ef:00:01') and HH:MM:SS timestamps were incorrectly guessed as ip-src/ip-dst. Added a new helper looks_like_ipv6_fragment() that requires genuine IPv6 group structure — either exactly 8 groups of 1-4 hex digits, or a single '::' compression with at most 7 total groups of 1-4 hex digits each — and replaced the old regex check with a call to it. This still catches partial/compressed IPv6 fragments (e.g. 'fe80::1') while rejecting 6-group 2-digit MAC addresses and 3-group timestamps.Verification
Reproduced against the unmodified code at
9b8c605, then re-checked after the change.Before
After
python bin/cli.py --helpexits 0 and the module still imports cleanly. Verification was performed offline against the pure functions — no runningmisp-modulesinstance is required.Branched from
9b8c605. This PR addresses only this finding; the other findings from the same review are in separate PRs, so they will need rebasing against each other as they merge.🤖 Generated with Claude Code