Skip to content

fs.stat crash program on invalid string #55914

Closed
libuv/libuv
#4609
@AjaniBilby

Description

@AjaniBilby

Version

v22.2.0

Platform

Microsoft Windows NT 10.0.22631.0 x64

Subsystem

No response

What steps will reproduce the bug?

This will crash the entire program not even recoverable with a try statement

import fs from "fs";
fs.stat("ᜄȺy𐞲:𞢢𘴇𐀀'¥3̞[<i$", function onstat (err, stat) {
	console.log("unreachable");
});

logs:

Assertion failed: w_target_len == 0, file c:\ws\deps\uv\src\idna.c, line 408

How often does it reproduce? Is there a required condition?

I think this might be windows only based on the libuv source

What is the expected behavior? Why is that the expected behavior?

Throw an error/call the actual callback with the error.

What do you see instead?

The entire program crashes

Additional information

I discovered this by performing a fuzz test on my remix.js site which uses express.js which uses fs.stat.
This can take down a production server no matter their routes with just a HTTP GET request as long as they have express.static or similar behaviour for static file serving.

See remix-run/remix#10241

Metadata

Metadata

Assignees

No one assigned

    Labels

    libuvIssues and PRs related to the libuv dependency or the uv binding.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions