AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 31 Bitcoin

Use `DirEntry::file_type` rather than `metadata...` in `list`

Public commit record

What the developer wrote

Authored by Matt Corallo

81/100 · Strong
Use `DirEntry::file_type` rather than `metadata...` in `list`

In the discussions at #3799 it was noted that `DirEntry::file_type`
will often use cached information rather than making a fresh
syscall, fixing the `list` race condition where we lose files while
iterating the directory for some filesystems on some Unix
platforms.

For some reason, that fix didn't make it into the merged PR, and we
rather stuck with `DirEntry::metadata()` which *always* does a
fresh syscall and always exhibits the problematic behavior. Here we
simply swap for `DirEntry::file_type` which at least fixes the
issue for "some filesome filesystems (among them: Btrfs, ext2,
ext3, and ext4)" (per `readdir(3)`).
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a subtle file-listing bug in the Lightning payment channel data storage code. When listing saved data, the program used to ask the filesystem for fresh details about each file, which on common Linux filesystems can briefly make a file appear missing if it is being changed at the same time. The change uses cached information already returned by the directory scan, avoiding that extra check and the race condition. It is a reliability fix rather than a direct exploit, but in the worst case it could cause the node to fail to load channel data it expected to find.

Recommended action

Treat as a low-risk reliability/robustness patch. Review whether the same metadata() pattern exists elsewhere in fs_store.rs or related persistence modules and apply the same fix if applicable. No urgent security response is indicated.

Security signals we found

01

Race condition in directory enumeration

02

TOCTOU-style metadata check

03

Filesystem persistence layer reliability

04

No input validation or crypto changes

Risk score

Why this scored 31/100

Our methodology →
Potential impact 8/30
Exploitability 3/25
Stealth signal 4/15
Affected reach 6/15
Confidence 7/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.