Skip to content

[high] fix: [btc_steroids] filter output transactions on their own value field - #888

Open
elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/079-btc-steroids-prev-out-filter
Open

[high] fix: [btc_steroids] filter output transactions on their own value field#888
elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/079-btc-steroids-prev-out-filter

Conversation

@elhoim

@elhoim elhoim commented Aug 31, 2026

Copy link
Copy Markdown
Member

BLUF — btc_steroids reads prev_out on output entries, so its zero-value filter never excludes anything.

  • Problem — The output loop in btc_steroids.py reads tx["prev_out"]["value"], but prev_out exists only on input entries, so the lookup always raises KeyError and the zero-value filter never excludes anything.
  • Fix — Reads tx["value"], the field actually present on out entries and already used to compute the displayed value.
  • Effect — Analysts enriching a bitcoin address now get real payments without zero-value OP_RETURN and dust outputs cluttering the enrichment result.

In btc_steroids.py, the loop over output transactions reads tx["prev_out"]["value"]:

for tx in transactions["out"]:
    ...
    try:
        prev_out = tx["prev_out"]["value"]
    except KeyError:
        prev_out = None
    if prev_out != 0 and addr_out == btc:

Entries in transactions["out"] never have a prev_out key — that field belongs to the input entries handled in the loop above (transactions["inputs"]). So the lookup always raises KeyError, prev_out is always set to None, and prev_out != 0 is always True. The zero-value filter therefore never filters anything.

Impact: an analyst enriching a bitcoin address/transaction via the btc_steroids expansion module gets zero-value outputs (e.g. OP_RETURN or dust outputs with value == 0) listed alongside real payments, cluttering the enrichment result with entries the filter was meant to exclude.

Fix: read tx["value"] directly, which is the field actually present on out entries (and is already the field used a few lines below to compute and print the displayed value), so the zero-value filter now works as intended.

No behaviour change beyond restoring the intended filtering (fewer, correctly-filtered lines in output; no API or module contract change).

Verification

  • flake8 on the changed file: clean, no output.
  • Module test suite: 161 passed, 4 skipped, 5 subtests passed in 32.77s.

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

🤖 Generated with Claude Code

The zero-value filter over transactions["out"] read tx["prev_out"]["value"],
but out entries never carry a prev_out key (that field belongs to the "inputs"
entries handled earlier in the same function). The KeyError was silently
caught and prev_out set to None, so the "prev_out != 0" guard was always true
and the filter never excluded zero-value outputs, letting spurious zero-value
lines through the enriched btc_steroids report.

Verified with flake8 (clean) and the full pytest suite: 161 passed, 4 skipped,
5 subtests passed, against a live modules server on port 6779.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
@elhoim elhoim changed the title fix: [btc_steroids] filter output transactions on their own value field [high] fix: [btc_steroids] filter output transactions on their own value field Sep 3, 2026
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