Skip to content

fix: [vt_graph_parser] split filename|hash on the last pipe - #893

Open
elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/085-vtgraph-hash-split
Open

fix: [vt_graph_parser] split filename|hash on the last pipe#893
elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/085-vtgraph-hash-split

Conversation

@elhoim

@elhoim elhoim commented Aug 31, 2026

Copy link
Copy Markdown
Member

The defect

if misp_type.startswith("filename|"):
    label, value = value.split("|")

MispAttribute.__init__ in misp_modules/lib/vt_graph_parser/helpers/wrappers.py splits a filename|hash MISP attribute value on | with no limit. str.split("|") on a value like report|final|v1.exe|44d88612fea8a8f36de82e1278abb02f returns more than two elements, and unpacking that into label, value raises ValueError: too many values to unpack, which aborts the entire VT Graph export.

Impact

Any MISP analyst exporting a filename|md5/filename|sha1/filename|sha256 composite attribute to VirusTotal Graph fails outright as soon as the filename itself contains a pipe character (a legal, unremarkable character in a filename). The whole export errors instead of just handling that one attribute.

The fix

Changed the split to value.rsplit("|", 1), splitting from the right so only the trailing hash token (which never contains |) is separated off, regardless of how many | characters appear in the filename portion.

No behaviour change for the common case (filenames without |); this only fixes the crash for filenames containing |.

Verification

  • py_compile clean on the changed file (it lives under misp_modules/lib/, so flake8's CI exclusions do not apply to it).
  • Full module test suite: 161 passed, 4 skipped, 5 subtests passed in 28.23s.

Found during a review of the repository; other findings are being submitted as separate PRs.

🤖 Generated with Claude Code

https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8

MispAttribute's constructor splits a `filename|hash` MISP attribute value
with a plain `value.split("|")`, which raises ValueError as soon as it
returns more than two parts. Any filename that itself contains a `|`
character (a legitimate byte in a filename) therefore aborts the whole
VT Graph export instead of exporting the attribute. The hash suffix is
always a single trailing token with no `|` in it, so splitting from the
right on the last pipe correctly separates an arbitrary filename from
the hash regardless of how many `|` characters the filename contains.

Verified with py_compile on the changed file and the full pytest suite
against a live modules server on port 6785: 161 passed, 4 skipped, 5
subtests passed, matching the documented baseline.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant