Skip to content

feat: basic fuzzing protection for model name and ios, android tokens - #217

Merged
subpath merged 4 commits into
mainfrom
feat-basic-fuzzing-protection
Jul 29, 2026
Merged

feat: basic fuzzing protection for model name and ios, android tokens#217
subpath merged 4 commits into
mainfrom
feat-basic-fuzzing-protection

Conversation

@subpath

@subpath subpath commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Description

Reject fuzzing/injection payloads on model, App Attest key_id_b64, and Play Integrity integrity_token before they cost a DB round trip or an external API call.

We were seeing scanner traffic (SQLi, XSS, code injection) landing in these free-text fields. None of it can actually do anything to this stack, but it still triggers a DB query or an external call (LiteLLM, Google Play Integrity) before getting rejected downstream.

Added plain charset + length checks, no whitelist to maintain:

  • model: lowercase ascii + digits + .-, max 64 chars, checked in authorize_chat_request before any auth/DB/LiteLLM work
  • key_id_b64 (App Attest challenge): base64 charset, max 128 chars, checked before the DB lookup
  • integrity_token (Play Integrity): JWT-like charset (-_. + alnum), max 10000 chars, checked before the Google API call

All garbage still gets a 400, just without the round trip.

QA

Unit tests table-driven over real model names / real-shaped tokens (should pass) and the sampled attack payloads (should reject), plus edge cases (empty, over length, bad edge chars). Integration tests confirm the downstream call (_decode_integrity_token, env.valid_service_type_for_model, fxa_auth) is never reached for rejected input, not just that the response is a 400.

@subpath
subpath requested a review from a team as a code owner July 28, 2026 09:02
Comment thread src/mlpa/core/utils.py Outdated
Comment thread src/mlpa/core/utils.py
Comment thread src/mlpa/core/auth/authorize.py
Comment thread src/mlpa/core/auth/authorize.py
@subpath
subpath merged commit 9e3cf00 into main Jul 29, 2026
3 checks passed
@subpath
subpath deleted the feat-basic-fuzzing-protection branch July 29, 2026 12:53
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.

2 participants