httpx is vulnerable to Remote Code Execution via Oj Object
httpx is vulnerable to Remote Code Execution via Oj Object-Mode JSON Deserialization
httpx (gitlab.com/os85/httpx)
httpx parses JSON response bodies through its transcoder layer. When the oj gem is loaded and multi_json is absent from the bundle, HTTPX::Response#json decodes the body with Oj.load(response.to_s) and no mode option (lib/httpx/transcoder/json.rb), so Oj runs in its shipped default :object mode. In that mode a JSON document can instantiate any already-loaded Ruby class and set its instance variables, which turns a fetched response body into attacker-controlled Ruby objects.
An attacker who can influence the URL an application fetches reaches this sink over the network with no user interaction. With ActiveSupport loaded, as in any Rails application, a universal gadget chain through ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy and ActiveSupport::Cache::Coder::LazyEntry reaches Kernel.load and executes an attacker-chosen file, giving remote code execution as the application user. The file can be staged without any upload feature: an ordinary multipart/form-data POST makes Rack materialize the body as a tempfile reachable through /dev/fd/N. Applications that keep multi_json installed, pin a safe process-wide Oj.default_options, or pass an explicit safe mode at the call site are not affected. Fixed in httpx 1.9.1.
Step 1 - Build and start a vulnerable httpx 1.9.0 service
The lab app loads oj before httpx, then ActiveSupport, and exposes POST /preview, which calls HTTPX.get(url).json on a client-supplied URL.
Step 2 - Stage the payload through an ordinary multipart POST
Rack materializes multipart file parts as tempfiles with live descriptors in the app process, so no upload feature is needed.
Step 3 - Point /preview at the gadget document
Serve a JSON document carrying the ActiveSupport chain, with value aimed at /dev/fd/N, and spray descriptor numbers downward until the staged tempfile executes:
Touching the parsed value (even preview['title']) enters DeprecatedInstanceVariableProxy#method_missing, which calls LazyEntry#value, which calls Kernel.load on the staged file.
Step 4 - Confirm code execution inside the container
Vulnerability Mitigations
Upgrade to httpx 1.9.1 or later. The fix passes an explicit { mode: :strict } default to Oj.load in lib/httpx/transcoder/json.rb, so response bodies can no longer instantiate Ruby objects. The change is commit eeb785d ("json: fix oj integration to avoid RCE mode") and is in the v1.9.1 tag.
If upgrading is not possible, pass a safe mode at the call site (response.json(mode: :strict)), or set a safe process-wide default such as Oj.default_options = { mode: :strict } before any untrusted JSON is parsed. Keeping multi_json in the bundle also avoids the Oj fallback entirely.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
