Skip to content

Real CVEs: PHP2Shell (CVE-2026-109619), October 2026

Real CVEMemory safetyIntermediate+135 -0

Click a line to select it, or press and drag down the changes to select a block (Shift-click works too). Then name the weakness and submit the finding. Each finding is marked as soon as you submit it. On the keyboard, Tab to a file's changes, move with the arrow keys, hold Shift to select a block, and press Enter to flag it.

Zend/zend_execute_API.cmodified+52-0
Zend/zend_execute_API.c
@@ -270,0 +270,14 @@
270+/* Free values held by the executor. */
271+ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
272+{
273+ zend_string *key;
274+ zval *zv;
275+
276+ EG(flags) |= EG_FLAGS_IN_RESOURCE_SHUTDOWN;
277+ zend_close_rsrc_list(&EG(regular_list));
278+
279+ /* No PHP callback functions should be called after this point. */
280+ EG(active) = 0;
281+
282+ if (!fast_shutdown) {
283+ zend_hash_graceful_reverse_destroy(&EG(symbol_table));
@@ -306,0 +306,6 @@
306+ } ZEND_HASH_MAP_FOREACH_END_DEL();
307+ }
308+
309+ zval_ptr_dtor(&EG(last_fatal_error_backtrace));
310+ ZVAL_UNDEF(&EG(last_fatal_error_backtrace));
311+
@@ -421,0 +421,11 @@
421+#if ZEND_DEBUG
422+ if (!CG(unclean_shutdown)) {
423+ gc_collect_cycles();
424+ }
425+#endif
426+ } else {
427+ zend_hash_discard(EG(zend_constants), EG(persistent_constants_count));
428+ }
429+
430+ zend_objects_store_free_object_storage(&EG(objects_store), fast_shutdown);
431+}
@@ -433,0 +433,21 @@
433+void shutdown_executor(void) /* {{{ */
434+{
435+ zend_string *key;
436+ zval *zv;
437+#if ZEND_DEBUG
438+ bool fast_shutdown = 0;
439+#elif defined(__SANITIZE_ADDRESS__)
440+ char *force_fast_shutdown = getenv("ZEND_ASAN_FORCE_FAST_SHUTDOWN");
441+ bool fast_shutdown = (
442+ is_zend_mm()
443+ || (force_fast_shutdown && ZEND_ATOL(force_fast_shutdown))
444+ ) && !EG(full_tables_cleanup);
445+#else
446+ bool fast_shutdown = is_zend_mm() && !EG(full_tables_cleanup);
447+#endif
448+
449+ zend_try {
450+ zend_stream_shutdown();
451+ } zend_end_try();
452+
453+ zend_shutdown_executor_values(fast_shutdown);
Zend/zend.cmodified+13-0
Zend/zend.c
@@ -1433,0 +1433,3 @@
1433+ZEND_API ZEND_COLD void zend_error_zstr_at(
1434+ int orig_type, zend_string *error_filename, uint32_t error_lineno, zend_string *message)
1435+{
@@ -1500,0 +1500,6 @@
1500+ // Always clear the last backtrace.
1501+ zval_ptr_dtor(&EG(last_fatal_error_backtrace));
1502+ ZVAL_UNDEF(&EG(last_fatal_error_backtrace));
1503+
1504+ /* Report about uncaught exception in case of fatal errors */
1505+ if (EG(exception)) {
@@ -1524,0 +1524,4 @@
1524+ }
1525+ } else if (EG(fatal_error_backtrace_on) && (type & E_FATAL_ERRORS)) {
1526+ zend_fetch_debug_backtrace(&EG(last_fatal_error_backtrace), 0, EG(exception_ignore_args) ? DEBUG_BACKTRACE_IGNORE_ARGS : 0, 0);
1527+ }
main/main.cmodified+70-0
main/main.c
@@ -1307,0 +1307,10 @@
1307+static void clear_last_error(void) {
1308+ if (PG(last_error_message)) {
1309+ zend_string_release(PG(last_error_message));
1310+ PG(last_error_message) = NULL;
1311+ }
1312+ if (PG(last_error_file)) {
1313+ zend_string_release(PG(last_error_file));
1314+ PG(last_error_file) = NULL;
1315+ }
1316+}
@@ -1345,0 +1345,2 @@
1345+static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, const uint32_t error_lineno, zend_string *message)
1346+{
@@ -1393,0 +1393,11 @@
1393+ /* store the error if it has changed */
1394+ if (display) {
1395+ clear_last_error();
1396+ if (!error_filename) {
1397+ error_filename = ZSTR_KNOWN(ZEND_STR_UNKNOWN_CAPITALIZED);
1398+ }
1399+ PG(last_error_type) = type;
1400+ PG(last_error_message) = zend_string_copy(message);
1401+ PG(last_error_file) = zend_string_copy(error_filename);
1402+ PG(last_error_lineno) = error_lineno;
1403+ }
@@ -1728,0 +1728,12 @@
1728+/* {{{ php_free_request_globals */
1729+static void php_free_request_globals(void)
1730+{
1731+ clear_last_error();
1732+ if (PG(php_sys_temp_dir)) {
1733+ efree(PG(php_sys_temp_dir));
1734+ PG(php_sys_temp_dir) = NULL;
1735+ }
1736+
1737+ EG(filename_override) = NULL;
1738+ EG(lineno_override) = -1;
1739+}
@@ -1956,0 +1956,3 @@
1956+void php_request_shutdown(void *dummy)
1957+{
1958+ bool report_memleaks;
@@ -2020,0 +2020,32 @@
2020+ /* 9. Shutdown scanner/executor/compiler and restore ini entries */
2021+ zend_deactivate();
2022+
2023+ /* 10. free request-bound globals */
2024+ php_free_request_globals();
2025+
2026+ /* 11. Call all extensions post-RSHUTDOWN functions */
2027+ zend_try {
2028+ zend_post_deactivate_modules();
2029+ } zend_end_try();
2030+
2031+ /* 12. SAPI related shutdown*/
2032+ zend_try {
2033+ sapi_deactivate_module();
2034+ } zend_end_try();
2035+ /* free SAPI stuff */
2036+ sapi_deactivate_destroy();
2037+
2038+ /* 13. free virtual CWD memory */
2039+ virtual_cwd_deactivate();
2040+
2041+ /* 14. Destroy stream hashes */
2042+ zend_try {
2043+ php_shutdown_stream_hashes();
2044+ } zend_end_try();
2045+
2046+ /* 15. Free Willy (here be crashes) */
2047+ zend_arena_destroy(CG(arena));
2048+ zend_interned_strings_deactivate();
2049+ zend_try {
2050+ shutdown_memory_manager(CG(unclean_shutdown) || !report_memleaks, 0);
2051+ } zend_end_try();

This challenge is Training Content. We encourage you to discuss it and to publish your own write-ups and videos of it. See the terms of service.

Opens in a new tab.