Skip to content

[medium] fix: [mobilebackup] is_compatible() raises TypeError when the case model is unknown - #247

Open
elhoim wants to merge 1 commit into
EC-DIGIT-CSIRC:mainfrom
elhoim:fix/mobilebackup-case-model-none
Open

[medium] fix: [mobilebackup] is_compatible() raises TypeError when the case model is unknown#247
elhoim wants to merge 1 commit into
EC-DIGIT-CSIRC:mainfrom
elhoim:fix/mobilebackup-case-model-none

Conversation

@elhoim

@elhoim elhoim commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

BLUF

  • Priority: medium. MobileBackupParser.is_compatible() raises TypeError: argument of type 'NoneType' is not iterable whenever the case metadata carries no model.
  • case_model is documented as optional. BaseInterface.case_model is typed str | None and returns self.case.get("model"), so None is a legitimate, expected value — but the device check does "AppleTV" not in self.case_model with no guard.
  • The blast radius is the whole run, not this parser. BaseInterface._execute_and_write() calls is_compatible() outside its own try/except crash guard, so the TypeError is not caught, escapes Sysdiagnose.parse(), and aborts the entire invocation — every remaining parser and every remaining case is skipped.
  • Fix: coalesce to "" before the substring test. A case with an unknown model is treated as compatible, which is the safe default for a forensic tool — better to run the parser and produce nothing than to skip it silently.
  • Scope: 3 changed lines in one parser, plus a regression test. No base-class change.

Reproducing

Any case whose cases.json entry has no model key — which happens whenever get_case_metadata() could not determine the device model from the archive:

case = {"case_id": "no-model", "ios_version": "16.0"}
MobileBackupParser(config, case=case).is_compatible()
# TypeError: argument of type 'NoneType' is not iterable

The fix

# case_model is None when the case metadata carries no model; treat that as compatible
case_model = self.case_model or ""
device_compatibility = "AppleTV" not in case_model and "Watch" not in case_model

This parser is not compatible with Apple TV or Apple Watch, and that exclusion is preserved exactly.

Test

test_is_compatible_without_case_model builds a case dict with no model, asserts case_model is None, and asserts is_compatible() returns a bool instead of raising. Verified to fail on main with the exact TypeError above and pass with this change.

Note

Sibling parsers (mcstate_shared_profile, itunesstore, networkextension) carry the identical unguarded pattern. They are submitted as separate PRs so each can be reviewed and reverted independently.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@elhoim
elhoim force-pushed the fix/mobilebackup-case-model-none branch 2 times, most recently from 78026f8 to d8ab0b3 Compare September 9, 2026 07:30
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