Skip to content

Kernelguard pre-queue check addition#473

Open
SinatrasC wants to merge 4 commits intogpu-mode:mainfrom
SinatrasC:sinatras/kguard-impl
Open

Kernelguard pre-queue check addition#473
SinatrasC wants to merge 4 commits intogpu-mode:mainfrom
SinatrasC:sinatras/kguard-impl

Conversation

@SinatrasC
Copy link
Contributor

Summary

Integrates KernelGuard as a submission pre-check gate that detects and rejects exploit submissions before GPU execution. The check runs at the API boundary, before queue enqueue on the async path and before GPU dispatch on the sync path, so blocked payloads never consume worker resources. Flagged submissions are recorded with a "hacked" status in the database. The feature is off by default (KERNELGUARD_ENABLED) and supports both fail-open and fail-closed modes for handling analyzer outages.

Changes

  • New: src/libkernelbot/kernelguard.py - CLI wrapper for kernelguard tool with env-var configuration
  • New: tests/test_kernelguard.py - unit tests for mode gating, rejection, fail-open/closed
  • Modified: backend.py - precheck in submit_full() with skip_precheck flag, submission_started guard
  • Modified: main.py - precheck before enqueue_background_job() in async endpoint
  • Modified: api_utils.py - catch KernelGuardRejected (400) and KernelBotError (503) separately
  • Modified: background_submission_manager.py - handle KernelGuardRejected with "hacked" job status
  • Modified: leaderboard_db.py - mark_submission_hacked() method
  • Modified: pyproject.toml - add kernelguard>=0.1.1, bump requires-python to >=3.11

Environment Variables

Variable Purpose Default
KERNELGUARD_ENABLED Master switch off
KERNELGUARD_TIMEOUT_SEC CLI subprocess timeout 30s
KERNELGUARD_PROFILE Built-in profile (default/strict/generic) none
KERNELGUARD_CONFIG Path to TOML config none
KERNELGUARD_FAIL_OPEN Allow submissions when CLI unavailable off
KERNELGUARD_COMMAND Override CLI command auto-detect

Test plan

  • test_kernelguard.py — 6 tests: mode gating, rejection, fail-open, fail-closed, CLI delegation
  • test_backend.py — 2 tests: hacked submission recording with/without pre_sub_id
  • test_background_submission_manager.py — 1 test: hacked status propagation
  • Manual: enable KERNELGUARD_ENABLED=1 on staging, submit known exploit, verify 400 rejection
  • Manual: stop kernelguard binary, verify fail-closed returns 503
  • Manual: set KERNELGUARD_FAIL_OPEN=1, verify submissions pass through on outage

SinatrasC and others added 4 commits March 20, 2026 01:48
- Introduced KernelGuard for validating submissions before processing.
- Implemented error handling for rejected submissions in the backend.
- Updated database methods to mark submissions as hacked when flagged.
- Enhanced tests to cover new KernelGuard functionality and error scenarios.
- Added a new kernelguard.py module for managing submission analysis and pre-checks.
- Updated Python version requirement from 3.10 to 3.11 in pyproject.toml and uv.lock.
- Added `kernelguard` dependency to manage submission pre-checks.
- Enhanced error handling in submission processes to include KernelGuard rejection scenarios.
- Implemented pre-check logic in the submission workflow to prevent blocked submissions from queuing.
- Updated tests to reflect changes in submission handling and pre-check logic.
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