Skip to content

Harden DEPS parsing and sanitize revision metadata handling - #5438

Merged
vitaliset merged 8 commits into
masterfrom
fix-issue-534004999
Sep 1, 2026
Merged

Harden DEPS parsing and sanitize revision metadata handling#5438
vitaliset merged 8 commits into
masterfrom
fix-issue-534004999

Conversation

@vitaliset

Copy link
Copy Markdown
Collaborator
  • Replace dynamic evaluation in DEPS parsing with a restricted AST-based parser.
  • Add revision string format validation and template-based URL formatting.
  • Sanitize issue metadata across uworker post-processing tasks before persistence.
  • Escape revision identifiers in testcase detail fallback rendering.

b/534004999

TAG=agy
CONV=6fa9c8c8-6088-4c02-b27d-ab873dda019f

vitaliset and others added 6 commits August 24, 2026 03:47
- Replace unrestricted exec() in deps_to_revisions_dict() with a safe AST evaluator (_SafeDepsEvaluator).
- Validate revision string identifier against REVISION_PATTERN in get_component_revisions_dict() to reject URL manipulation / query delimiters.
- Validate and sanitize numeric metadata fields (e.g. last_tested_crash_revision) in _update_issue_metadata().
- Add comprehensive unit tests covering safe AST parsing, malicious DEPS payloads, and revision format validation.
- Extract is_valid_revision() helper for clean identifier validation.
- Split _SafeDepsEvaluator node processing into dedicated helpers (_eval_literal, _eval_binop, _eval_call, _eval_dict, _eval_sequence, _process_assignment).
- Extract _sanitize_metadata_value() helper in progression_task.py.
- Add test_is_valid_revision unit tests.
- Define explicit MetadataValue = Union[str, int, float, bool, None] in progression_task.py.
- Add concrete type annotations for AST evaluator helper methods and revision validation in revisions.py.
- Move the numeric-metadata allowlist into
  data_handler.sanitize_issue_metadata() and apply it in
  corpus_pruning_task as well. It had the same unvalidated write of
  uworker issue_metadata into Datastore, so the poisoning primitive
  survived the progression_task fix.
- Escape the revisions in show._get_revision_range_html()'s "No
  component revisions found!" fallback. That string is bound with
  inner-h-t-m-l, and a rejected revision now always routes to it.
- Select the response parser in get_component_revisions_dict() from the
  REVISION_VARS_URL format string rather than the interpolated url.
- Drop the dead ast.Str/ast.Num branches (Python 3.8+ only emits
  ast.Constant) and extract type aliases so annotations fit in 80
  columns.
- Replace typing.Optional and typing.Union with | None and | syntax.
- Replace typing.Dict and typing.Tuple with builtin dict and tuple generics.
@vitaliset
vitaliset requested a review from a team as a code owner August 26, 2026 15:09
@vitaliset

vitaliset commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Verification

  • Development Deployment:
    • Deployed to the development environment and validated against live App Engine traffic and active worker bot fleets.
    • Monitored real-time telemetry and error logs across fuzzing workloads with zero parsing exceptions or regressions observed.

Compatibility & Risk Assessment

  • Safe DEPS Parsing: Fully supports all standard DEPS structures (string assignments, Var() lookups, lists, dictionaries, tuples) without altering expected dependency resolution behavior.
  • Revision Validation: The validation pattern (^[a-zA-Z0-9._-]+$) covers all standard git commit hashes, SVN numbers, semantic versions, and release tags.
  • Metadata Sanitization & Escaping: Operates purely as defensive validation on untrusted inputs without affecting valid pipeline data.

@ViniciustCosta ViniciustCosta left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sanitize DEPS logic is difficult for me to review, as I don't have context about this. Seems good to me given your tests on dev :)

Comment thread src/clusterfuzz/_internal/build_management/revisions.py Outdated
Comment thread src/clusterfuzz/_internal/build_management/revisions.py Outdated
Comment thread src/clusterfuzz/_internal/datastore/data_handler.py
@vitaliset
vitaliset merged commit 397d7be into master Sep 1, 2026
14 of 15 checks passed
@vitaliset
vitaliset deleted the fix-issue-534004999 branch September 1, 2026 13: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.

2 participants