-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"Gravity Forms's `set_uploaded_files` function in `forms_model.php` walks every uploaded-file dictionary in `$_POST['gform_uploaded_files']` and applies a sanitizer to each of four string fields. `uploaded_filename` passes through `sanitize_file_name( wp_basename( ... ) )`. `temp_filename` passes through `sanitize_file_name( wp_basename( ... ) )`. `id` passes through `sanitize_key()`. The fourth field, added to the dictionary's contract in version 2.9.18, is named `url`, and it passes through `esc_url_raw()`.\n\nCVE-2026-48866 is what happens when a function picks four sanitizers across four fields by the field's name, and the field that named itself a URL is the field whose value reaches `unlink()`.\n\n## The `url` key was added in September 2025 to a dictionary the function had been basenaming since 2.4.3.\n\nLines 8595 through 8615 of `forms_model.php` at tag 2.10.0, the released version the CVE names, read in full:\n\n```php\nforeach ( $input_files as $key => &$file ) {\n if ( empty( $file ) ) {\n unset( $input_files[ $key ] );\n continue;\n }\n\n // All files regardless of upload or population method should have this.\n if ( isset( $file['uploaded_filename'] ) ) {\n $file['uploaded_filename'] = sanitize_file_name( wp_basename( $file['uploaded_filename'] ) );\n }\n\n // All multi-file uploads should have this. Single file uploads should have it once a submission or pagination request has been processed.\n if ( isset( $file['temp_filename'] ) ) {\n $file['temp_filename'] = sanitize_file_name( wp_basename( $file['temp_filename'] ) );\n }\n\n // Used when the field is dynamically populated on initial form display.\n if ( isset( $file['url'] ) ) {\n $file['url'] = esc_url_raw( $file['url'] );\n }\n\n // Sanitize or generate the UUID to be used by the file preview and error messages markup.\n if ( isset( $file['id'] ) ) {\n $file['id'] = sanitize_key( $file['id'] );\n } else {\n $file['id'] = GFFormsModel::get_uuid();\n }\n}\n```\n\nThe function's `@since` block is the file's own admission of when each branch landed. The `uploaded_filename` and `temp_filename` clauses date to 2.4.3.5, December 2019. The `url` clause was added in 2.9.18, September 19, 2025. The function's docstring records the addition explicitly: \"Added support for dynamically populated file URLs using the `url` key.\"\n\nThe inline comment on the `url` branch is the entire mental model the developer brought to the work: \"Used when the field is dynamically populated on initial form display.\" `esc_url_raw` is the WordPress idiom for a URL string about to be stored for later display in HTML attributes. The function the developer reached for was the function for the destination they were thinking about, which was the form's rendered preview.\n\nThe runtime treats the same field as a filesystem locator. The two `wp_basename` calls six lines above are the codebase's standing acknowledgment that file-related fields in this exact dictionary can flow to `unlink()` and need their path components stripped. They are in the same function. Same iteration. Same `foreach`. The developer added the `url` clause adjacent to them and chose a different sanitizer because the field's key was `url`.\n\n## From `gform_uploaded_files` to `unlink()` is one string and one `str_replace`.\n\nThe `url` value the visitor submits is cached on the form context, attached to the entry record, and never re-canonicalized. The path the value walks to reach the delete site is the four function calls below, each one a method on a different class, none of them with a check that the URL it is handing forward still points at the uploads directory.\n\nThe injection site, with no authentication required for an `action=gform_submit_form` call to `admin-ajax.php`, registers via `wp_ajax_nopriv_gform_submit_form`. The submitted JSON body for one form field:\n\n```json\n{\n \"input_3\": [\n {\n \"url\": \"https://target.com/wp-content/uploads/gravity_forms/../../../wp-config.php\",\n \"uploaded_filename\": \"legitimate.txt\",\n \"id\": \"poc-file-1\"\n }\n ]\n}\n```\n\n`uploaded_filename` is `legitimate.txt`. The value will survive `sanitize_file_name(wp_basename(...))` unchanged and will be what the WordPress admin sees in the entries list. `id` is alphanumeric. `url` carries the entire payload.\n\nAfter `set_uploaded_files` returns, `GF_Field_FileUpload::get_multifile_value` reads the cached dictionary, walks the existing-files branch for any entry without a `temp_filename` (which is the dynamically-populated case), and serializes `$existing_file_url` into the JSON-encoded array that becomes the entry-meta field value. The URL is now in the database, intact.\n\nHours later, weeks later, on a routine entries-page cleanup, the admin selects the entry and clicks delete. `GFFormsModel::delete_files` runs, decoding the same JSON array and calling `delete_physical_file($file, $lead_id)` once per stored URL. `delete_physical_file` at lines 2490 through 2523:\n\n```php\nprivate static function delete_physical_file( $file_url, $entry_id ) {\n\n $ary = explode( '|:|', $file_url );\n $url = rgar( $ary, 0 );\n if ( empty( $url ) ) {\n return;\n }\n\n $file_path = self::get_physical_file_path( $url, $entry_id );\n\n $file_path = apply_filters( 'gform_file_path_pre_delete_file', $file_path, $url );\n\n if ( file_exists( $file_path ) ) {\n $result = unlink( $file_path );\n // ...\n }\n}\n```\n\nNo check between `get_physical_file_path` and `unlink`. The function hands the URL to a path-resolution helper, runs the result through a third-party filter, and unlinks whatever returns. `get_physical_file_path` itself, at line 2537:\n\n```php\npublic static function get_physical_file_path( $url, $entry_id = null ) {\n $path_info = GF_Field_FileUpload::get_file_upload_path_info( $url, $entry_id );\n\n if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {\n $file_path = preg_replace( \"|^(.*?)/files/gravity_forms/|\", BLOGUPLOADDIR . 'gravity_forms/', $url );\n } else {\n $file_path = str_replace( trailingslashit( $path_info['url'] ), trailingslashit( $path_info['path'] ), $url );\n }\n\n return $file_path;\n}\n```\n\n`$path_info['url']` is the uploads URL root, `https://target.com/wp-content/uploads/gravity_forms/`. `$path_info['path']` is the filesystem root, `/var/www/html/wp-content/uploads/gravity_forms/`. `str_replace` replaces the URL prefix with the filesystem prefix and returns:\n\n```\n/var/www/html/wp-content/uploads/gravity_forms/../../../wp-config.php\n```\n\nPHP's `file_exists` resolves the `../../../` against the actual filesystem layout. PHP's `unlink` does the same. The OS deletes `/var/www/html/wp-config.php`. The site stops serving requests. On the next page load, WordPress sees no database configuration and displays the installer wizard, offering to set up a fresh WordPress install on the existing domain.\n\nThe CVSS vector is `AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H`, 9.6. `UI:R` is the admin's delete click. Nothing else in the chain requires a credential.\n\n## The patch defends at the third address.\n\nThe 2.10.1 release ships [commit `cf2ff65`](https://github.com/codewurker/gravityforms/commit/cf2ff65133d581cfed1c308adc1621c3af1f8422), which closes the demonstrated chain by adding a guard inside `delete_physical_file`. The diff against the vulnerable `forms_model.php`:\n\n```diff\n $file_path = apply_filters( 'gform_file_path_pre_delete_file', $file_path, $url );\n\n+// If the file is outside the uploads folder, something nefarious is up, so bail.\n+if ( ! GFCommon::is_file_in_uploads( $url ) ) {\n+ GFCommon::log_debug( __METHOD__ . sprintf( '(): Not deleting file from URL: %s', $file_path ) );\n+ return;\n+}\n+\n if ( file_exists( $file_path ) ) {\n $result = unlink( $file_path );\n```\n\nThe new helper, added to `common.php` in the same commit:\n\n```php\npublic static function get_absolute_path( $path ) {\n $path = str_replace( array( '/', '\\\\' ), DIRECTORY_SEPARATOR, $path );\n $path = str_replace( '://', '|%%protocol%%|', $path );\n $parts = array_filter( explode( DIRECTORY_SEPARATOR, $path ), 'strlen' );\n $absolutes = array();\n\n foreach ( $parts as $part ) {\n if ( '.' == $part ) { continue; }\n if ( '..' == $part ) {\n array_pop( $absolutes );\n } else {\n $absolutes[] = $part;\n }\n }\n\n $path = implode( DIRECTORY_SEPARATOR, $absolutes );\n return str_replace( '|%%protocol%%|', '://', $path );\n}\n\npublic static function is_file_in_uploads( $file ) {\n $file_path = self::get_absolute_path( $file );\n $root_url = rgar( GF_Field_FileUpload::get_file_upload_path_info( '' ), 'url' );\n\n if ( ! str_starts_with( $file_path, $root_url ) ) {\n return false;\n }\n\n return true;\n}\n```\n\nThe patch's design choice is visible in where it landed. `is_file_in_uploads` is called at the delete sink, not at the storage source. The committer had three places they could have intervened.\n\nThe first option was to normalize the URL at storage in `set_uploaded_files`, adding a `..` walk to the existing `esc_url_raw` call so the stored value can never carry a traversal. This would have required the smallest code change and would have aligned the `url` branch's defensive posture with the `wp_basename` calls immediately above it. The patch did not choose this.\n\nThe second option was to validate the URL at storage in `set_uploaded_files`, rejecting any value whose resolved path falls outside the uploads root before it reaches the database. This would have closed the bug at the point of entry and preserved the database invariant that every stored file URL points inside `/wp-content/uploads/gravity_forms/`. The patch did not choose this either.\n\nThe third option, the one the patch took, was to validate at the sink in `delete_physical_file`. This closes the demonstrated chain. The database can still hold a URL with `../` in it for an entry that exists but has not been deleted; the storage path is unchanged. The asymmetry inside `set_uploaded_files` between `wp_basename`d filename fields and `esc_url_raw`d URL field is preserved verbatim in the patched release. The fix is a check in front of `unlink`. The shape that made the check necessary is still in the file.\n\nThe release notes for 2.10.1 enumerate the change in the changelog at `changelog.txt`, alongside a long list of unrelated polish: \"Fixes a path traversal vulnerability that could allow form submissions to specify file paths outside the uploads directory.\" The line names the destination correctly. It does not name the storage-side sanitizer asymmetry that surfaced the bug.\n\n## Sanitized The Secrets, Not The Sink, in the file-upload dialect.\n\nThe pattern's catalog entry, [Sanitized The Secrets, Not The Sink](/patterns/sanitized-the-secrets-not-the-sink), names the shape: a function applies escape, quote, or sanitize logic to user-controlled fields the developer perceives as security-sensitive, and omits it on a field that actually flows into the dangerous interpreter. The mitigation logic in the same function is proof the developer understood the threat. The unsanitized field is proof they sorted by perceived field role rather than by destination.\n\nThe catalog already carries the shape five times. [ASUSTOR's `vpn.cgi`](/posts/asustor-vpn-escapes-credentials-not-server) escaping the username and password it writes into a pppd peer config and skipping the server-address field on the same line, all three reaching `/bin/sh -c` through pppd's pty handler. [OPNsense's `local_user_set`](/posts/opnsense-cve-2026-44193-escapeshellarg-was-the-camouflage) applying `escapeshellarg()` to the free-form GECOS comment and interpolating the six adjacent shell arguments raw. [Keras's `deserialize_keras_object`](/posts/keras-cve-2025-1550-safe-mode-not-in-the-patch) gating the `__lambda__` branch with `safe_mode` and resolving the parallel `module + class_name` path through `importlib.import_module` unguarded. [Easy Elements](/posts/easy-elements-cve-2026-9018-hardened-role-looped-meta) hardening the `role` field through a denylist of dangerous capabilities and looping over `$_POST['custom_meta']` into the same WordPress capabilities map. [BentoML's Dockerfile loop](/posts/bentoml-cve-2026-44346-env-name-was-not-env-value) running `bash_quote` on `env.value` and rendering `env.name` on the same line raw.\n\nGravity Forms is the shape at a WordPress filter callback. Six lines above the `url` branch, the same function strips path components from `uploaded_filename` and `temp_filename`. The `wp_basename` calls are the codebase's standing acknowledgment that file-related fields can carry `..` and that values arriving from the network must have it stripped before they reach the filesystem. The author of the `url` clause was reading the same function. The author chose `esc_url_raw` because the field's key was `url`.\n\nThe asymmetry is internally consistent if you read the field name as the destination's name. Filenames go through file-name sanitizers. URLs go through URL sanitizers. Identifiers go through key sanitizers. The function is sorted by what each field is. The system the function lives in sorts by where each field goes, and the destination for all three filesystem-bound fields is the same: a `str_replace` six thousand lines away builds a path the OS resolves, and `unlink` deletes whatever the path names.\n\nThe bug also fits a second catalog frame. [The Shell Was Not The Sink](/patterns/the-shell-was-not-the-sink) names the cross-interpreter mistake the `esc_url_raw` choice embodies in isolation: `esc_url_raw` is the WordPress idiom for a value about to be stored or rendered as a URL, with a transformation set written for HTML-attribute and database contexts. The function's name encodes the threat model the developer was thinking about, which is `href` injection and storage-side XSS. The destination encodes the threat model they were not, which is filesystem traversal through PHP's `unlink`. Both frames are accurate. The within-function asymmetry frame is the sharper one here because the function itself contains the proof the developer understood the filesystem boundary, applied immediately above the field the patch had to close.\n\nThe patch closes CVE-2026-48866. The next file-upload add-on that registers a new field on this dictionary, with a key name reading to its author as anything other than \"filename,\" and a destination ending in a filesystem operation, is the next instance.\n\n## Coverage stack\n\n- NVD record: [CVE-2026-48866](https://nvd.nist.gov/vuln/detail/CVE-2026-48866)\n- Patchstack advisory: [Gravity Forms Plugin <= 2.10.0.1 Arbitrary File Deletion](https://patchstack.com/database/wordpress/plugin/gravityforms/vulnerability/wordpress-gravity-forms-plugin-2-10-0-1-arbitrary-file-deletion-vulnerability)\n- Vulnerable storage clause at line 8605: [`forms_model.php@86bf7b9`](https://github.com/codewurker/gravityforms/blob/86bf7b9ecf14fd4a826a741a1ae180040589ebed/forms_model.php#L8605)\n- Patched delete-site guard: [`forms_model.php@cf2ff65`](https://github.com/codewurker/gravityforms/commit/cf2ff65133d581cfed1c308adc1621c3af1f8422)\n- PoC: [0xABCD01/CVE-2026-48866](https://github.com/0xABCD01/CVE-2026-48866)\n","closing_line":"`esc_url_raw` is named for the destination it was written to defend. `unlink()` is one of the destinations it was not.","hook_md":"Gravity Forms's `set_uploaded_files` function in `forms_model.php` walks every uploaded-file dictionary in `$_POST['gform_uploaded_files']` and applies a sanitizer to each of four string fields. `uploaded_filename` passes through `sanitize_file_name( wp_basename( ... ) )`. `temp_filename` passes through `sanitize_file_name( wp_basename( ... ) )`. `id` passes through `sanitize_key()`. The fourth field, added to the dictionary's contract in version 2.9.18, is named `url`, and it passes through `esc_url_raw()`.\n\nCVE-2026-48866 is what happens when a function picks four sanitizers across four fields by the field's name, and the field that named itself a URL is the field whose value reaches `unlink()`.","post_id":561,"slug":"gravity-forms-cve-2026-48866-url-was-the-third-field","title":"CVE-2026-48866: Gravity Forms Basenamed Two File Fields. The Third Field's Name Was `url`.","type":"initial","unreadable_sentence":"`uploaded_filename`, `temp_filename`, and `url` are three filesystem-bound fields in the same dictionary. Two of them are `wp_basename`d in the same function. The third is the field delete used."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaqsCFwAKCRDeZjl4jgkQ JgZxAQDjLcafh1bopMbicRTo0WLQtv+VD2ZwUuY4BhTF27luEQD9G6zO6XQ9TIrL 9IJVwjrHHa5flWgGF+0wd8p3ElmGWwk= =HS5l -----END PGP SIGNATURE-----