GeezerVison is showing github.com — Security CI: ASAN/UBSAN + CodeQL by pronskiy · Pull Request #27 · php-debugger/php-debugger
Conversation
What
Add two security-focused CI workflows:
- ASAN + UBSAN — Builds PHP from source with AddressSanitizer and UndefinedBehaviorSanitizer, then runs the full test suite. Catches memory bugs (use-after-free, buffer overflow, fd leaks, signed overflow) at runtime.
- CodeQL — GitHub semantic analysis with
security-extended queries. Catches common C vulnerability patterns statically (every push/PR + weekly).
Trimmed from the original PR #8 — removed Cppcheck and Clang Static Analyzer (overlap with CodeQL, noisy on inherited Xdebug code).
Attack Surface Analysis
This PR is informed by a threat model of the extension. Key vectors:
Network — DBGp (TCP :9003)
| Vector |
Severity |
Status |
Unauthorized debug attach — anyone reaching :9003 gets code exec via eval |
Critical |
Mitigated by localhost-only default; IDE connection prompts planned (SPEC §7.2) |
| Malicious DBGp client — crafted XML to crash extension (buffer overflow, XXE) |
High |
Inherited Xdebug XML parser, not yet audited post-fork |
| Connection flood / DoS — exhaust FDs via connection spam |
Medium |
No rate limiting yet |
| MitM on DBGp — plaintext XML, sniffable on non-localhost |
Medium |
Spec recommends localhost-only |
Memory Safety (C extension)
| Vector |
Severity |
Status |
| Use-after-free — socket FD reuse after close |
High |
Fixed in PR #11 (socket = -1 after close) |
| FD leak — failed init does not close socket |
Medium |
Fixed in PR #11 |
| Buffer overflow in DBGp parser — inherited Xdebug XML parsing |
High |
This PR adds ASAN + CodeQL to catch these |
| Stack overflow — deep recursion in variable serialization |
Medium |
max_depth INI limits this |
Information Disclosure
| Vector |
Severity |
Status |
| Variable inspection exposes secrets — eval/inspect reads env vars, passwords |
Critical |
By design (dev tool only, SPEC §1) |
| Stack traces leak paths |
Low |
Unavoidable for a debugger |
Not Applicable (yet)
- Signal handler safety — profiler SIGPROF not implemented yet (Phase 4)
- Trigger injection — auto-connect default makes triggers irrelevant
- Network sniffing — localhost only in default config
Files
.github/workflows/sanitizers.yml — ASAN + UBSAN on PHP 8.3, 8.4
.github/workflows/codeql.yml — CodeQL with security-extended queries
Supersedes #8.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.
What Enabling Code Scanning Means:
- The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
- Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
- You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.
For more information about GitHub Code Scanning, check out the documentation.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@pronskiy I've never used these two tools so I am not really sure what we are expecting to see here. I tried to see the results of the CodeQL scan but they seemed empty. And the ASAN + UBSAN test run was full of errors. Do you have more info on what we are expected to see or how to interpret the results?
One thing: for the CodeQL scan we should use V4 of the GitHub action, V3 is deprecated as far as I can tell from the run output
And in the ASAN + UBSAN check you need to update the version of the actions/cache GitHub action as V4 is also deprecated
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
pronskiy
commented
Apr 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for the review, @carlos-granados! Good catch on the CodeQL action version — bumped to v4 now.
As for what to expect from these:
- ASAN/UBSAN is the main value here — runtime detection of memory safety bugs (use-after-free, buffer overflows, leaks, undefined behavior). For a C extension that hooks into the Zend Engine, seems critical.
- CodeQL is a static analyzer — lower value for our use case but essentially free to run. It may catch some patterns (format strings, taint flows) but ASAN/UBSAN hopefully will catch far more real bugs at runtime.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- CodeQL: semantic analysis with security-extended queries (every push/PR + weekly)
- ASAN + UBSAN: runtime sanitizers, builds PHP from source with sanitizer flags (every push/PR)
- Cppcheck: fast static analysis for leaks, null derefs, fd leaks (every push/PR)
- Clang Static Analyzer: path-sensitive analysis via scan-build (weekly + manual dispatch)
The hash destructor callback was declared as taking
struct xdebug_fiber_entry * but registered as xdebug_hash_dtor_t
(void (*)(void *)). Calling through the mismatched pointer type
is undefined behavior per C11 §6.5.2.2.
Fix: accept void * and cast inside the function body.
Zero performance impact — identical generated code.
The DBGp test client had hardcoded 3s/5s socket timeouts. Under ASAN
(2-3x slower), PHP takes longer to respond, causing false test failures.
Fix: make timeouts configurable via DBGP_TIMEOUT env var (defaults
unchanged). Set DBGP_TIMEOUT=10 in the sanitizer CI workflow.
Parallel ASAN-instrumented PHP processes compete for CPU on CI runners,
causing DBGp socket timeouts. Run with -j1 for reliable results.
The ASAN-instrumented test suite has ~36-45 test output mismatches
(known XFAIL tests + ASAN-induced timing differences). These are
not memory bugs.
The CI now runs all tests, captures output, and fails ONLY when
actual sanitizer errors are detected (AddressSanitizer, LeakSanitizer,
UBSAN runtime errors). Test output mismatches are logged but
do not block the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's give this a go and see if we get some helpful info
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
pronskiy reacted with thumbs up emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
ci
CI/CD, GitHub Actions, testing infrastructure
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|