Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ etcetera = "0.11.0"
reqwest = { version = "0.12.4", features = ["blocking"] }
tokio = { version = "1.44.2", features = ["rt", "rt-multi-thread"] }

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.59", features = ["Win32_System_LibraryLoader"] }

[target.'cfg(target_os = "wasi")'.dependencies]
wasi = "0.14"
wstd = "0.5"
Expand Down
17 changes: 17 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,23 @@ fn print_reader(reader: &Reader, detailed: bool, crjson: bool) -> Result<()> {
}

fn main() -> Result<()> {
// Harden against DLL hijacking on Windows by removing the current working
// directory from the DLL search path. Without this, Windows' default DLL
// search order includes the CWD, which allows an attacker to place a
// malicious DLL alongside the executable. LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
// restricts the search to: the application directory, System32, and
// directories added via AddDllDirectory/SetDllDirectory — excluding the CWD.
// SAFETY: no invariants to uphold; the argument is a valid constant.
#[cfg(windows)]
unsafe {
if windows_sys::Win32::System::LibraryLoader::SetDefaultDllDirectories(
windows_sys::Win32::System::LibraryLoader::LOAD_LIBRARY_SEARCH_DEFAULT_DIRS,
) == 0
{
bail!("Failed to set default DLL directories");
}
}

let args = CliArgs::parse();

// set RUST_LOG=debug to get detailed debug logging
Expand Down
Loading