Skip to content

apply reports a passenger gem patch as applied while the downloaded agent it runs is unchanged; on main the rebuild runs 16 minutes and its product is discarded silently #2144

Closed

Description

[agent] Filed from an investigation of passenger GHSA-7cv3-gvmc-8mq5 (patchpedia #11445).

Summary

For a gem whose only extension downloads a standalone binary (passenger), socket-patch apply reports 1 of 1 targeted patch applied while the binary the gem runs is byte-for-byte unchanged. On main (911bf163) the apply also spends 16.5 minutes on a rebuild whose product is not installed anywhere, and prints nothing about it.

Why passenger is different

passenger ships its agent as C++ under src/agent/. Its gemspec declares one extension, src/helper-scripts/download_binaries/extconf.rb, which writes a dummy Makefile and downloads Phusion's precompiled agent-<arch>.tar.gz into <gem>/download_cache/. On first start the gem installs that binary to <gem>/buildout/support-binaries/PassengerAgent. It compiles its own C++ only when no download succeeds. So the file Ruby runs is not an extension RubyGems built and not a rake-compiler prebuilt: it is a separate executable the gem's own Ruby code places.

Reproduction (ruby:2.5, linux/amd64)

  1. gem install passenger -v 5.3.1, then passenger-config install-standalone-runtime --auto. Phusion's agent is installed: 6,057,376 bytes, sha256 bb81445f93fcb914….
  2. Build a manifest the way the harness does (manifest.json + blobs/ + prepatch/, purl pkg:gem/passenger@5.3.1) and run socket-patch apply --manifest-path .socket/manifest.json --cwd . --global --offline --force.
  3. Hash buildout/support-binaries/PassengerAgent again and run passenger start --runtime-check-only.

Case A: v5.1.0 (release), patch changes a C++ header and a Ruby file

Patch: src/agent/Core/SecurityUpdateChecker.h and src/ruby_supportlib/phusion_passenger.rb (empties binaries_sites).

  • apply exits 0 in 2 s: Patched packages: pkg:gem/passenger@5.3.1 (via blob), Summary: 1 of 1 targeted patch applied.
  • Agent hash unchanged. passenger start --runtime-check-only passes in 0.3 s on the old binary.

Case B: main 911bf163, patch also changes the gem's extconf.rb to build the agent from source

Patch: the two files above plus src/helper-scripts/download_binaries/extconf.rb, whose download calls are replaced by passenger-config compile-agent --auto --force, aborting if the build fails.

  • apply exits 0 after 16 m 33 s with the same three lines as Case A and nothing about a rebuild (no native_extension_rebuilt, no warning).
  • Agent hash unchanged (bb81445f93fcb914…). A search of the filesystem after apply finds no other PassengerAgent, so whatever the rebuild produced was not kept.
  • passenger start --runtime-check-only passes in 0.8 s on the old binary.

I did not capture the rebuild's own log, so I cannot say whether the compile inside it succeeded or failed. Either way the outcome reported to the user is the same.

What is wrong

  1. The result says "applied" for a patch that changed build inputs and changed nothing that runs. A security patch to passenger's C++ reads as applied while the vulnerable agent keeps serving. I did not test VEX output; anything that attests on a successful apply would attest this one.
  2. On main, the rebuild's product is discarded silently. The contract says the build is put "where Ruby loads it". For this gem that place is <gem>/buildout/support-binaries/, which the extension writes relative to the tree it runs in. If the build runs in a stage, the binary lands in the stage.
  3. 16.5 minutes with no output. Nothing tells the user a build is running or what it did.

Suggested handling

  • When a record changes build inputs of a native gem and the rebuild installs nothing into the live gem tree (or no rebuild runs), do not report the patch as applied without qualification, and withhold VEX, as is already done for other unverifiable cases.
  • Say when a rebuild starts and how it ended, even on success.
  • Decide whether in-tree products of an extension build (files the extension writes under the gem directory outside lib/ and the extension dir) should be carried from the stage into the live tree, or whether such a gem should be refused with native_extensions_unsupported and a message naming the cause.

Not asking for

Support for building passenger's agent. The patch side can handle that without the CLI (the patched gem refuses the old binary and builds its source on next start, which works on v5.1.0). This issue is about the misleading result and the silent, discarded rebuild.

Environment

  • Docker ruby:2.5 (Debian buster, gcc 8.3, libcurl 7.64), linux/amd64 under emulation on an arm64 host, which is why the build is slow.
  • v5.1.0: release asset socket-patch-x86_64-unknown-linux-musl.tar.gz, checksum verified against SHA256SUMS.
  • main: 911bf163, built with cargo zigbuild --release --target x86_64-unknown-linux-musl -p socket-patch-cli. It reports socket-patch 5.1.0, since the workspace version has not changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpm:bundler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions