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

Merged
merged 4 commits into from
Jan 7, 2025

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 72.93%. Comparing base (906cbc5) to head (7c8f668).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2836      +/-   ##
============================================
- Coverage     74.80%   72.93%   -1.87%     
  Complexity     2781     2781              
============================================
  Files           112      139      +27     
  Lines         11017    15166    +4149     
  Branches          0     1022    +1022     
============================================
+ Hits           8241    11062    +2821     
- Misses         2776     3552     +776     
- Partials          0      552     +552     
Flag Coverage Δ
appsec-extension 67.99% <ø> (?)
tracer-php 74.80% <ø> (ø)

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

see 27 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 906cbc5...7c8f668. 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 2 times, most recently 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-12-26 11:33:25

Comparing candidate commit e459810 in PR branch estringana/blocking-within-tracer-hook with baseline commit 4cc2897 in branch master.

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

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟩 execution_time [-6.415µs; -4.045µs] or [-3.750%; -2.365%]

scenario:PDOBench/benchPDOBaseline-opcache

  • 🟥 execution_time [+12.800µs; +16.942µs] or [+7.143%; +9.455%]

scenario:TraceFlushBench/benchFlushTrace

  • 🟩 execution_time [-1000.000ns; -1000.000ns] or [-50.000%; -50.000%]

@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch 2 times, most recently 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.

zend_abstract_interface/sandbox/sandbox.h Show resolved Hide resolved
@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch from 1602d2c to ee5bff3 Compare December 12, 2024 11:39
zend_abstract_interface/sandbox/sandbox.h Show resolved Hide resolved
return false;
}

if (strcmp("Datadog blocked the request and presented a static error page", ZSTR_VAL(PG(last_error_message))) == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

My main concern with this approach is that if someone changes the error message in appsec, it would stop working. Can you make changes on the appsec side to:

  • Make sure the error messages are validated at compile time?
  • Add comments specifying that the error message must not be changed.

zend_abstract_interface/sandbox/sandbox.h Outdated Show resolved Hide resolved
zend_abstract_interface/sandbox/sandbox.h Show resolved Hide resolved
@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch from ee5bff3 to 7fd4a50 Compare December 16, 2024 15:15
@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch 2 times, most recently from 3b1c027 to 491a2e8 Compare December 26, 2024 09:25
@estringana estringana marked this pull request as ready for review December 26, 2024 11:05
@estringana estringana requested review from a team as code owners December 26, 2024 11:05
Copy link
Collaborator

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@estringana estringana force-pushed the estringana/blocking-within-tracer-hook branch from e459810 to 7c8f668 Compare January 7, 2025 09:50
@estringana estringana merged commit 4a6498d into master Jan 7, 2025
773 of 800 checks passed
@estringana estringana deleted the estringana/blocking-within-tracer-hook branch January 7, 2025 11:51
@github-actions github-actions bot added this to the 1.6.0 milestone Jan 7, 2025
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.

5 participants