Skip to content

NuGet and Cargo crawlers hang on a FIFO at obj/project.assets.json or vendor/<crate>/Cargo.toml #592

Description

[agent] Filed by the scheduled architecture audit routine (ecosystems and formats). Register: E06.

Kind: bug. Source: review Part 6.6 ("FIFO safety"); register E06.

Problem

The crawlers' FIFO-safe read discipline (utils::fs::read_regular_to_string / read_regular_to_string_sync, a non-blocking open that rejects FIFOs, devices and directories) is missing from three reads of project-tree files. A FIFO planted at one of these paths blocks the open forever, so scan, get and apply hang:

  • NuGet parse_project_assets_package_folders reads obj/project.assets.json and <sub>/obj/project.assets.json with tokio::fs::read_to_string. It runs from get_nuget_package_paths and so from every NuGet crawl.
  • Cargo read_crate_cargo_toml (crawl_all) reads vendor/<crate>/Cargo.toml with std::fs::read_to_string.
  • Cargo verify_crate_at_path (find_by_purls) does the same with tokio::fs::read_to_string.

The sibling crawlers already guard the same kind of read: python parse_metadata_headers,`` composer, npm and ruby.

Repro (unit tests, each run twice on main 203e092):

  • NuGet: a temp project with App.csproj and mkfifo obj/project.assets.json. NuGetCrawler::get_nuget_package_paths was still pending after 3 s (timed_out=true).
  • Cargo: a temp project with Cargo.toml and mkfifo vendor/left-1.0.0/Cargo.toml. CargoCrawler::crawl_all and find_by_purls(vendor, ["pkg:cargo/left@1.0.0"]) were both pending after 3 s.

The probes weren't committed.

Symptoms

None filed. The review's other example, python_crawler.rs .venv at L1214-L1215,`` is guarded by is_file() and only has a TOCTOU window, so it isn't part of this issue.

Impact

A checked-out repository (or a PR in CI) can wedge every socket-patch scan on it with one FIFO. The other crawlers were fixed for this bug class in #111. Size: three call sites.

Proposed change

Replace the three reads with read_regular_to_string (async) and read_regular_to_string_sync (in the blocking-pool scan_crate_source). Keep today's "unreadable means skip" behavior. Nothing else is deleted; the shared readers already exist.

Size and scope

crawlers/nuget_crawler.rs, crawlers/cargo_crawler.rs: about 10 production lines plus tests. Out of scope: the Maven POM reads at maven_crawler.rs L498 and L813, which read the machine repository, not the project tree. Follow-up: an architecture test that bans bare read_to_string in crawlers/ outside #[cfg(test)].

Acceptance criteria

  • Regression tests: a FIFO at obj/project.assets.json (NuGet) and at vendor/<crate>/Cargo.toml (Cargo crawl_all and find_by_purls) returns within 1 s, and the crawl skips the entry.
  • cargo test -p socket-patch-core --lib crawlers and the crawler oracle suites stay green.

Dependencies

None. Independent of the E05 cache-scoping work.

Activity

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

    agent:claimedagent:triagedarch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)bugSomething isn't workingpriority:p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions