Skip to content

fix: Enforce non-zero positive sandbox timeouts to prevent indefinite hangs (#1808) - #2050

Open
Rakshak05 wants to merge 4 commits into
utksh1:mainfrom
Rakshak05:issue-#1808
Open

fix: Enforce non-zero positive sandbox timeouts to prevent indefinite hangs (#1808)#2050
Rakshak05 wants to merge 4 commits into
utksh1:mainfrom
Rakshak05:issue-#1808

Conversation

@Rakshak05

Copy link
Copy Markdown
Contributor

Description

This PR addresses a vulnerability/bug where a falsy sandbox timeout_seconds value (0, negative, or None) allowed subprocess execution and reader tasks to run indefinitely without a wall-clock limit. If a scanner hung, the process would run forever.

To resolve this:

  • Added a @field_validator to SandboxConfig in models.py that raises a ValidationError / ValueError and logs a warning if timeout_seconds is <= 0 or None.
  • Added a @field_validator to Settings in config.py that checks both sandbox_timeout and parser_sandbox_timeout_seconds, raising a ValidationError / ValueError and logging a warning if they are <= 0 or None.
  • Added accompanying unit tests to verify validation behaviors for both models and settings.

Related Issues

Closes #1808

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

Ran the updated unit test suite targeting config settings and sandbox configurations:

python -m pytest testing/backend/unit/test_sandbox_config_model.py testing/backend/unit/test_config_settings.py testing/backend/test_sandbox_executor.py testing/backend/test_sandbox_blocking_issues.py

Results: All 78 tests passed.

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

@Rakshak05 Rakshak05 changed the title Resolves issue-#1808 fix: Enforce non-zero positive sandbox timeouts to prevent indefinite hangs (#1808) Jul 21, 2026
@utksh1 utksh1 added level:beginner 20 pts difficulty label for small beginner-friendly PRs type:bug Bug fix work category bonus label area:backend Backend API, database, or service work labels Jul 24, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The positive-timeout validation is narrowly scoped, but the branch is behind main. Please rebase and add a regression test through the actual task/sandbox configuration path, not only model/settings tests, then rerun CI.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please add coverage for the execution path that previously accepted 0/None, not only model validation. Confirm that environment/config parsing cannot silently create an unbounded timeout, then rebase on main.

@Rakshak05
Rakshak05 force-pushed the issue-#1808 branch 2 times, most recently from 27355b9 to c329718 Compare July 24, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:bug Bug fix work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#35] No timeout when sandbox timeout_seconds is 0/None

2 participants