Skip to content

[medium] fix: [anyrun_sandbox_import] require both API key and analysis UUID - #839

Open
elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/029-anyrun-import-require-both-config
Open

elhoim wants to merge 1 commit into
MISP:mainfrom
elhoim:fix/029-anyrun-import-require-both-config

Conversation

@elhoim

@elhoim elhoim commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

BLUF — A half-configured ANY.RUN import module now fails with its own clear error message.

  • Problem — The config guard in anyrun_sandbox_import.py uses if not any((token, analysis_uuid)), which only fires when both values are missing, so a module configured with just the API key or just the Analysis UUID passes a None into SandboxConnector.windows() and the downstream parser.
  • Fix — Changes any to all so the guard matches its own error message, which already states that both must be specified.
  • Effect — A misconfigured module fails with the clear "API-KEY and Analysis UUID must be specified" message instead of an opaque error from the ANY.RUN SDK.

The config guard in anyrun_sandbox_import.py used any() instead of all():

token = request.get("config").get("api_key")
analysis_uuid = request.get("config").get("ANYRUN Analysis UUID")

if not any((token, analysis_uuid)):
    raise RunTimeException("ANY.RUN API-KEY and Analysis UUID must be specified.")

not any((token, analysis_uuid)) is only true when both values are missing, so supplying just one of the two lets a None flow straight into SandboxConnector.windows(token, ...) and the downstream parser. This contradicts the module's own error message, which says both values "must be specified."

Impact on a MISP user: a user who misconfigures the module with only the API key (or only the Analysis UUID) set does not get the clear "API-KEY and Analysis UUID must be specified" message. Instead the request fails later with an opaque error from the ANY.RUN SDK or parser, making misconfiguration much harder to diagnose.

Fix: changed any to all, so the guard now raises whenever either value is missing, matching the error message's stated requirement. This is a one-token change with no other behavior impact.

No security default or contract was changed — this only makes an existing validation check match its own documented intent.

Verification

  • flake8 --extend-exclude=misp_modules/lib/,tests/,website/ on the changed file: clean, no output.
  • Module test suite: 161 passed, 4 skipped, 5 subtests passed in 108.79s (0:01:48).

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

🤖 Generated with Claude Code

The handler guards its configuration with `if not any((token, analysis_uuid))`, which
only raises when both values are missing. When an analyst configures just one of them —
an API key without an ANYRUN Analysis UUID, or the reverse — the guard passes and the
`None` value flows straight into `SandboxConnector.windows(token, ...)` and the parser.
The clear "ANY.RUN API-KEY and Analysis UUID must be specified." error is never shown;
instead the import fails later with an opaque authorization or unspecified-exception
message that hides the real, trivially fixable cause. Switching the check to `all`
makes the guard match the error message it raises.

Verified with flake8 on the changed module and the full test suite against a local
modules server: 161 passed, 4 skipped, 5 subtests passed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
@elhoim elhoim changed the title fix: [anyrun_sandbox_import] require both API key and analysis UUID [medium] fix: [anyrun_sandbox_import] require both API key and analysis UUID Sep 3, 2026

This branch has not been deployed

No deployments
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