Skip to content

Add sandbox execution audit records #21

Description

@johnny603

Lux runs submitted scripts inside a restricted Docker sandbox. The current execution path captures useful result data, but audit records need to consistently describe every execution so operators can investigate failures and timeouts without logging user-submitted source code.

Add privacy-conscious audit events around sandbox execution. Each event should identify the job and puzzle, record timing and outcome details, distinguish Docker failures from timeouts, and preserve cleanup behavior.

Because sandbox.py currently receives files and a script but does not receive a puzzle ID, the implementation should define a small, documented way for the caller to provide that ID, such as an optional puzzle_id argument.

Steps / Implementation Plan

  • Review sandbox.py and sandbox_audit.py.
  • Add a puzzle ID to the sandbox execution context without logging submitted source or file contents.
  • Ensure every execution produces one audit event, including:
    • Successful execution
    • Non-zero exit code
    • Docker command failure
    • Timeout
    • Input validation failure, if it reaches the execution boundary
  • Include a unique job ID, puzzle ID, runtime, duration, exit code, timeout status, and normalized result.
  • Represent Docker failures separately from timeouts, using stable result or error values that tests can assert.
  • Preserve the existing best-effort behavior if writing the audit log fails.
  • Confirm temporary sandbox directories are removed on success, failure, timeout, and exceptions.
  • Keep raw submitted source out of audit events by default.
  • Add focused tests in tests/test_server_sandbox.py.
  • Add or update audit writer tests if needed for JSON Lines output and configurable log paths.

Relevant Files

Acceptance Criteria

  • Each sandbox execution writes one audit event when audit logging is available.
  • Each event has a job ID, puzzle ID, runtime, duration, exit code, timeout status, and result.
  • Job IDs are unique for separate executions.
  • Duration is recorded in a non-negative, documented unit.
  • Raw submitted source and submitted file contents are not logged by default.
  • Successful executions and non-zero exit codes are represented accurately.
  • Docker failures and timeouts are represented distinctly and can be identified from the event fields.
  • Audit-write failures do not crash or change the sandbox result.
  • Temporary directories are removed after successful executions.
  • Temporary directories are also removed after Docker failures, timeouts, validation errors, and unexpected exceptions.
  • Tests verify all required event fields, privacy behavior, distinct failure states, and cleanup behavior.

Help / Mentorship

Ask questions in the issue before changing the audit event schema, especially around the distinction between Docker failures and timeouts. Maintainers can help with mocking subprocess.run, selecting a temporary audit path, and checking cleanup behavior without requiring Docker to run locally.

Estimated Effort

Medium


This repo is using Opire - what does it mean? 👇
💵 Everyone can add rewards for this issue commenting /reward 100 (replace 100 with the amount).
🕵️‍♂️ If someone starts working on this issue to earn the rewards, they can comment /try to let everyone know!
🙌 And when they open the PR, they can comment /claim #21 either in the PR description or in a PR's comment.

🪙 Also, everyone can tip any user commenting /tip 20 @johnny603 (replace 20 with the amount, and @johnny603 with the user to tip).

📖 If you want to learn more, check out our documentation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions