Skip to content

fix(security): remove regex timeout race - #1748

Merged
Aaronontheweb merged 2 commits into
devfrom
fix/windows-regex-timeout-race
Aug 3, 2026
Merged

fix(security): remove regex timeout race#1748
Aaronontheweb merged 2 commits into
devfrom
fix/windows-regex-timeout-race

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Summary

  • Replace scanner regex timeouts with the .NET non-backtracking engine.
  • Keep every threat pattern unchanged.
  • Remove wall-clock dependence from prompt-injection scans.
  • Preserve linear work for untrusted input.

Cause

The Windows runner paused DiskDestructionRegex for longer than its one-second timeout.

The short test input did not cause excessive backtracking. The timeout measured scheduler delay and threw after the thread resumed.

Failure: https://github.com/netclaw-dev/netclaw/actions/runs/30855724493/job/91826160402

Validation

  • dotnet test src/Netclaw.Security.Tests/Netclaw.Security.Tests.csproj -c Release --no-restore
  • The exact failed test passed in 25 isolated processes.
  • dotnet test Netclaw.slnx -c Release --no-restore
  • dotnet slopwatch analyze
  • pwsh ./scripts/Add-FileHeaders.ps1 -Verify
  • git diff --check

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request removes regex match timeouts from RegexPromptInjectionDetector and switches to the .NET non-backtracking engine. This change reduces false failures from scheduler delay and keeps linear-time regex work for untrusted input.

Changes:

  • Replace per-pattern matchTimeoutMilliseconds usage with RegexOptions.NonBacktracking.
  • Centralize regex options into shared constants for text and Unicode patterns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Netclaw.Security/RegexPromptInjectionDetector.cs Outdated
Copilot AI review requested due to automatic review settings August 3, 2026 23:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@Aaronontheweb Aaronontheweb added the bug Something isn't working label Aug 3, 2026
@Aaronontheweb
Aaronontheweb merged commit e997978 into dev Aug 3, 2026
22 checks passed
@Aaronontheweb
Aaronontheweb deleted the fix/windows-regex-timeout-race branch August 3, 2026 23:52
@Aaronontheweb Aaronontheweb mentioned this pull request Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants