Skip to content

Commit 432afbc

Browse files
authored
Merge pull request #57 from doublegate/security/fix-code-scanning-alerts
Security: Fix all 58 code scanning vulnerability alerts
2 parents 704ae8b + 70375ed commit 432afbc

File tree

25 files changed

+101
-30
lines changed

25 files changed

+101
-30
lines changed

.github/workflows/docs.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@ jobs:
5858
- name: Check for broken links
5959
uses: lycheeverse/lychee-action@v2
6060
with:
61-
args: >-
61+
args: |
6262
--verbose
6363
--no-progress
64-
--accept 200,204,301,302,403,429
65-
--exclude '^mailto:'
66-
--exclude '^https://github\.com/.*/(commit|compare)/'
67-
--exclude '^https://crates\.io/crates/'
68-
--exclude '^https://docs\.rs/'
69-
--exclude 'localhost'
70-
--exclude '127\.0\.0\.1'
71-
--exclude '\.local$'
72-
--timeout 30
73-
--max-retries 3
74-
--max-concurrency 10
64+
--accept=200,204,301,302,403,429
65+
--exclude='^mailto:'
66+
--exclude='^https://github\.com/.*/(commit|compare)/'
67+
--exclude='^https://crates\.io/crates/'
68+
--exclude='^https://docs\.rs/'
69+
--exclude='localhost'
70+
--exclude='127\.0\.0\.1'
71+
--exclude='\.local$'
72+
--timeout=30
73+
--max-retries=3
74+
--max-concurrency=10
7575
'./**/*.md'
7676
'./README.md'
7777
fail: false

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ members = [
3232

3333
# Excluded: wraith-xdp requires eBPF toolchain; spectre-implant is no_std with
3434
# custom #[panic_handler] and #[global_allocator] incompatible with workspace
35-
# feature unification (std linked through shared deps)
35+
# feature unification (std linked through shared deps); fuzz/ is cargo-fuzz managed
3636
exclude = [
3737
"crates/wraith-xdp",
3838
"clients/wraith-redops/spectre-implant",

clients/wraith-android/app/src/main/rust/src/keystore.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ pub extern "C" fn Java_com_wraith_android_WraithKeystore_getIdentityPublicKey(
339339

340340
// Reconstruct the signing key to get the public key
341341
if secret_bytes.len() != 32 {
342-
log::error!("Invalid secret key length: {}", secret_bytes.len());
342+
// Avoid logging actual length to prevent information leakage about key material
343+
log::error!("Invalid secret key length (expected 32 bytes)");
343344
return std::ptr::null_mut();
344345
}
345346

clients/wraith-redops/spectre-implant/src/modules/shell.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ impl Shell {
7979

8080
let sh = b"/bin/sh\0";
8181
let arg1 = b"-c\0";
82+
// Sensitive: cmd may contain credentials. Zeroize after use.
8283
let mut cmd_c = Vec::from(cmd.as_bytes());
8384
cmd_c.push(0);
8485

@@ -91,7 +92,8 @@ impl Shell {
9192
let envp = [core::ptr::null()];
9293

9394
sys_execve(sh.as_ptr(), argv.as_ptr(), envp.as_ptr());
94-
cmd_c.zeroize(); // Only reached if execve fails
95+
// Zeroize if execve returns (on failure); on success the process image is replaced and cmd_c is discarded.
96+
cmd_c.zeroize();
9597
sys_exit(1);
9698
} else {
9799
// Parent

clients/wraith-share/src-tauri/src/link_share.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ mod tests {
505505
let (db, _state, manager) = create_test_env();
506506
let file = create_test_file(&db);
507507

508+
// SECURITY: Intentional test password, not production credential
508509
let options = ShareLinkOptions {
509510
expires_in_hours: None,
510511
password: Some("secret123".to_string()),

clients/wraith-vault/src-tauri/src/integration_tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
//!
33
//! These tests verify the complete workflow of secret creation,
44
//! distribution, and recovery using the vault system.
5+
//!
6+
//! SECURITY NOTE: All hard-coded cryptographic values in this file are intentional
7+
//! test data for integration testing, NOT production secrets.
58
69
use crate::database::Database;
710
use crate::guardian::{

crates/wraith-cli/src/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,18 +707,20 @@ async fn receive_files(
707707
node.start().await?;
708708

709709
let listen_addr = node.listen_addr().await?;
710+
711+
// Extract count before logging to avoid cleartext logging of sensitive trusted_peer_ids variable
712+
let trusted_peer_count = trusted_peer_ids.len();
713+
710714
println!("WRAITH Receive Mode");
711715
println!("Version: {}", env!("CARGO_PKG_VERSION"));
712716
println!();
713717
println!("Node ID: {}", hex::encode(node.node_id()));
714718
println!("Listening on: {}", listen_addr);
715719
println!("Output directory: {}", output.display());
716720
println!("Auto-accept: {}", auto_accept);
717-
if !trusted_peer_ids.is_empty() {
718-
println!("Trusted peers: {}", trusted_peer_ids.len());
719-
for (idx, peer_id) in trusted_peer_ids.iter().enumerate() {
720-
println!(" {}: {}", idx + 1, hex::encode(&peer_id[..8]));
721-
}
721+
if trusted_peer_count > 0 {
722+
// Log only the count, not actual peer IDs to avoid cleartext logging
723+
println!("Trusted peers: {} configured", trusted_peer_count);
722724
}
723725
println!();
724726
println!("Ready to receive files. Press Ctrl+C to stop");

crates/wraith-core/src/transfer/session.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ pub struct TransferSession {
125125
/// Current state
126126
state: TransferState,
127127

128-
/// Bitmap tracking transferred chunks (bit = 1 means transferred)
128+
/// Bitmap tracking transferred chunks (bit = 1 means transferred).
129+
///
129130
/// Uses `Vec<u64>` as a bitset: `chunk_bitmap[idx/64] & (1 << (idx%64))`
130131
chunk_bitmap: Vec<u64>,
131132
/// Count of transferred chunks (cached for O(1) access)

crates/wraith-crypto/benches/crypto_bench.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
//! - AEAD encryption: >3 GB/s (single core)
77
//! - Noise handshake: <50ms (full XX)
88
//! - Key ratcheting: >10M ops/sec
9+
//!
10+
//! SECURITY NOTE: All hard-coded cryptographic values in this file are intentional
11+
//! test data for benchmarking, NOT production keys.
912
1013
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
1114
use rand::RngCore;

crates/wraith-crypto/src/aead/cipher.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ mod tests {
453453

454454
#[test]
455455
fn test_aead_roundtrip() {
456+
// SECURITY: Intentional test vector data, not production keys
456457
let key = [0x42u8; 32];
457458
let nonce = [0x00u8; 24];
458459
let plaintext = b"Hello, WRAITH!";
@@ -468,6 +469,7 @@ mod tests {
468469

469470
#[test]
470471
fn test_aead_tamper_detection() {
472+
// SECURITY: Intentional test vector data, not production keys
471473
let key = [0x42u8; 32];
472474
let nonce = [0x00u8; 24];
473475
let plaintext = b"Hello, WRAITH!";
@@ -541,6 +543,7 @@ mod tests {
541543

542544
#[test]
543545
fn test_nonce_from_counter() {
546+
// SECURITY: Intentional test vector data, not production keys
544547
let salt = [0x42u8; 16];
545548
let nonce1 = Nonce::from_counter(0, &salt);
546549
let nonce2 = Nonce::from_counter(1, &salt);

0 commit comments

Comments
 (0)