Skip to content

fix(detector): detect mutated capture subscript replay#126

Closed
prasannakotyal wants to merge 1 commit into
gpu-mode:mainfrom
prasannakotyal:kg-blue-148-mutated-capture-subscript-replay
Closed

fix(detector): detect mutated capture subscript replay#126
prasannakotyal wants to merge 1 commit into
gpu-mode:mainfrom
prasannakotyal:kg-blue-148-mutated-capture-subscript-replay

Conversation

@prasannakotyal

Copy link
Copy Markdown

Summary

Targets KG red #148, where custom_kernel mutates a captured container with an input-derived value through .extend(...), then returns a subscript of that same captured container from an input-independent fast path.

This adds a narrow MUTATED_CAPTURE_SUBSCRIPT_REPLAY detector. It requires:

  • captured names referenced by the entrypoint but not input parameters or top-level local name targets
  • mutation of a captured container through input-derived AugAssign, global assignment, or mutating methods such as .append, .extend, .insert, .update, and .setdefault
  • an if replay branch whose test does not reference input parameters
  • a call-free replay body returning a subscript of the mutated capture directly, or a local alias assigned from that subscript

Legitimate local containers, input-dependent guards, and replay bodies that perform calls stay out of scope.

KernelGuard-Red-Submission: 148

Local verification

  • red_28_list_extend_replay -> MUTATED_CAPTURE_SUBSCRIPT_REPLAY, should_filter=True
  • red_25_list_insert_replay -> MUTATED_CAPTURE_SUBSCRIPT_REPLAY, should_filter=True
  • red_41_dict_setdefault_replay -> MUTATED_CAPTURE_SUBSCRIPT_REPLAY, should_filter=True
  • red_95_dict_comprehension_update_replay -> MUTATED_CAPTURE_SUBSCRIPT_REPLAY, should_filter=True
  • clean fixtures in eval_blue_patch.py stayed valid
  • uv run python -m py_compile kernelguard.py

@prasannakotyal prasannakotyal temporarily deployed to kernelguard-api-control-plane May 1, 2026 23:52 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

KernelGuard Blue Evaluation

@SinatrasC

Copy link
Copy Markdown
Collaborator

Thanks for the KernelGuard Flywheel Campaign contribution. We are not merging this narrow variant separately because the consolidated rule-family implementation in #273 is the merge path for this detector area.

@SinatrasC SinatrasC closed this Jun 20, 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.

2 participants