Fix PSR-18 client memory management & harden UploadedFile::moveTo() security#10
Merged
Merged
Conversation
…ecurity Memory Management: - Convert malloc/free/strdup/realloc to Zend equivalents (emalloc/efree/estrdup/erealloc) - Affects: client.c, curl_easy.c, curl_multi_pool.c, curl_worker.c, request_data.c, response_data.c - Ensures proper PHP memory manager integration and request-scoped cleanup - Fixes potential memory tracking issues under PHP's memory_limit Security Hardening (UploadedFile::moveTo): - Add null byte injection prevention (path truncation attack) - Require absolute paths to prevent ambiguity - Improve traversal detection: check for /../ sequences, not just ".." substring - Add realpath() validation to resolve symlinks and verify directory exists - Handle root directory paths (/filename) correctly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR addresses two critical areas in the signalforge_http extension:
1. PSR-18 HTTP Client Memory Management Fix
Converted all standard C memory functions to Zend memory management equivalents across the entire client subsystem:
malloc()emalloc()calloc()ecalloc()realloc()erealloc()free()efree()strdup()estrdup()Why this matters:
memory_limitsetting2. UploadedFile::moveTo() Security Hardening
Strengthened path validation in
moveTo()to prevent several attack vectors:memchr()check rejects embedded\0/)/../sequences (not just..substring)realpath()resolves symlinks before validationrealpath()verifies directory existsBefore: Simple
strstr(path, "..")check (false positives onfile..name.txt)After: Proper
/../sequence detection + canonical path resolution