Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocking from a hook is not stopping code execution #2836

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

estringana
Copy link
Contributor

Description

Blocking a request from Appsec should stop customer code execution. However, when this blocking happens within a tracer hook, it does not stop executing customer code execution.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@estringana estringana changed the title Replicate issue on a PHPT tests Blocking from a hook is not stopping code execution Sep 5, 2024
@codecov-commenter
Copy link

codecov-commenter commented Sep 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.72%. Comparing base (0c6532b) to head (1602d2c).

❗ There is a different number of reports uploaded between BASE (0c6532b) and HEAD (1602d2c). Click for more details.

HEAD has 7 uploads less than BASE
Flag BASE (0c6532b) HEAD (1602d2c)
tracer-php 11 4
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             master    #2836       +/-   ##
=============================================
- Coverage     74.82%   49.72%   -25.10%     
+ Complexity     2741     2736        -5     
=============================================
  Files           110      110               
  Lines         10863    10858        -5     
=============================================
- Hits           8128     5399     -2729     
- Misses         2735     5459     +2724     
Flag Coverage Δ
tracer-php 49.72% <ø> (-25.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 50 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c6532b...1602d2c. Read the comment docs.

@bwoebi
Copy link
Collaborator

bwoebi commented Sep 5, 2024

I see, the tracer sandboxing is sandboxing the bailout away :-)
I suppose some it would be ideal to signal the tracer "please bailout again after catching this" :-D

@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch from c5d1d67 to 1d93a16 Compare September 6, 2024 13:09
@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch from 1d93a16 to 78a05a9 Compare October 7, 2024 13:23
@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch from 78a05a9 to dedee17 Compare November 27, 2024 11:23
@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch from dedee17 to 3438fca Compare November 28, 2024 11:47
@pr-commenter
Copy link

pr-commenter bot commented Nov 29, 2024

Benchmarks [ tracer ]

Benchmark execution time: 2024-11-29 16:40:28

Comparing candidate commit 1602d2c in PR branch estringana/blocking-within-tracer-hook with baseline commit 0c6532b in branch master.

Found 0 performance improvements and 2 performance regressions! Performance is the same for 176 metrics, 0 unstable metrics.

scenario:HookBench/benchHookOverheadTraceMethod

  • 🟥 execution_time [+5.734µs; +13.745µs] or [+2.726%; +6.534%]

scenario:PDOBench/benchPDOBaseline

  • 🟥 execution_time [+14.839µs; +18.347µs] or [+8.382%; +10.363%]

@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch from e086d75 to 8322005 Compare November 29, 2024 16:06
@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch from 8322005 to 1602d2c Compare November 29, 2024 16:12
Copy link
Contributor

@cataphract cataphract left a comment

Choose a reason for hiding this comment

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

I think it's fine although it's a mystery to me why sandbox.{h,c} are written the way they are.

inline void zai_sandbox_bailout(zai_sandbox *sandbox) {
if (!zai_sandbox_timed_out()) {
if (!zai_sandbox_timed_out() && !zai_is_request_blocked()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know why sandbox.h is written this way, with just C inline functions, but I guess that in the context of its strangeness it's fine.

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

Successfully merging this pull request may close these issues.

4 participants