Skip to content

fix(detector): direction coverage — JOIN/CONCAT-built dynamic dispatch detector#23

Closed
SinatrasC wants to merge 1 commit into
mainfrom
blue-direction-token-paste-kg-red-125
Closed

fix(detector): direction coverage — JOIN/CONCAT-built dynamic dispatch detector#23
SinatrasC wants to merge 1 commit into
mainfrom
blue-direction-token-paste-kg-red-125

Conversation

@SinatrasC

Copy link
Copy Markdown
Collaborator

Summary

Targets KG red #125 under "Direction — Token-paste / filter evasion in C++". Coverage example for the previously-empty direction; the red was submitted via the direct API path and is currently red_accepted: 1 on the live leaderboard.

Targets red #125 (filter-evasion via piecewise string construction).

This blue: JOIN/CONCAT-built dynamic dispatch detector.

Local verification

Patch was verified locally against a corpus that exercises:

  • the targeted red (must trigger)
  • the 5 other direction reds (untouched — each has its own paired patch)
  • 5 legitimate corpus cases (plain_kernel, workspace_lazy, shape_dispatch, config_lookup, triton_jit_kernel) — all stay valid
  • classic LAST_CALL_REPLAY (must still be flagged — no regression)

KernelGuard-Red-Submission: 125

Targets red #125 ('Token-paste / filter evasion'). Live KG (0.2.2) calls
this valid:

    def custom_kernel(data):
        name = ''.join(['e', 'x', 'e', 'c'])
        f = __builtins__[name] if isinstance(__builtins__, dict) else getattr(__builtins__, name)
        f('pass')
        return data.clone()

The literal 'exec' never appears in source, so the existing
detect_dynamic_execution Call-walking pass finds nothing.

Approach: add two detection branches in the same family as the chr-concat
rule (PR #15). Both flag piecewise string construction with >=3 short-
literal pieces, regardless of whether the result feeds into a dynamic-
dispatch site or not - that level of fragmentation has no legitimate use
in numerical kernels.

  * '".join([Constant, Constant, ...])' with all short-literal elts and
    len >= 3
  * 'BinOp(Add, ...)' chain whose leaves are all short-literal
    Constants and chain length >= 4

Verified locally: red #125 flagged, all 5 legit corpus cases stay valid,
classic LAST_CALL_REPLAY still flagged. The 5 other directions' reds are
untouched (they need their own per-direction patches).
@SinatrasC SinatrasC temporarily deployed to kernelguard-api-control-plane May 1, 2026 18:07 — 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 Author

Thanks for the KernelGuard Flywheel Campaign contribution. We are not selecting this PR for merge because it is too narrow or not aligned with the current consolidated rule-family surface.

@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.

1 participant