Skip to content
Closed
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
docs: security audit of hostile inputs, with failing parser PoCs
Record what the save, mod, weave, LLM, asset, net, and supply-chain
paths actually do, and add tests that fail until those parsers reject
oversized or out-of-root input. No parser behavior changes.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
  • Loading branch information
cursoragent and lazyxeon committed Oct 15, 2026
commit 5ae3a2e3c266e79c38d3de6eed123b709c0bd741
33 changes: 33 additions & 0 deletions astraweave-asset/tests/security_poc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//! SEC-POC tests. They assert the secure property and fail on today's loaders.
//! See `docs/current/SECURITY_AUDIT.md` (SEC-ASSET-1, SEC-ASSET-2).

use astraweave_asset::cell_loader::{load_asset, AssetKind, AssetRef};
use astraweave_asset::gltf_loader::load_first_mesh_and_material;

#[test]
fn poc_gltf_buffer_uri_rejects_parent_segments() {
let json = br#"{
"asset": { "version": "2.0" },
"buffers": [ { "uri": "../secret.bin", "byteLength": 4 } ]
}"#;
let err = load_first_mesh_and_material(json).expect_err("hostile glTF must not load");
let msg = format!("{err:#}");
assert!(
msg.to_lowercase().contains("traversal") || msg.to_lowercase().contains("rejected"),
"glTF buffer URI with parent segments was not rejected: {msg}"
);
}

#[tokio::test]
async fn poc_cell_asset_path_rejects_parent_segments() {
let root = tempfile::tempdir().expect("tempdir");
let asset = AssetRef::new("../outside.bin", AssetKind::Mesh);
let err = load_asset(&asset, root.path())
.await
.expect_err("hostile cell path must not load");
let msg = format!("{err:#}");
assert!(
msg.to_lowercase().contains("traversal") || msg.to_lowercase().contains("rejected"),
"cell asset path with parent segments was not rejected: {msg}"
);
}
37 changes: 37 additions & 0 deletions astraweave-combat/tests/security_poc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//! SEC-POC tests. They assert the secure property and fail on today's parser.
//! See `docs/current/SECURITY_AUDIT.md` (SEC-SAVE-2).

use astraweave_combat::decode_vitals;

/// A record list past 4_096 entries must be rejected. Four thousand is above
/// any combat fixture in this crate. Raising the cap later is fine if a real
/// save is larger; dropping the check is not.
#[test]
fn poc_vitals_rejects_more_than_4096_records() {
const COUNT: usize = 4_097;
const STRIDE: usize = 8 * 9;
let mut body = Vec::with_capacity(4 + COUNT * STRIDE);
body.extend_from_slice(&(COUNT as u32).to_le_bytes());
for i in 0..COUNT {
body.extend_from_slice(&(i as u64).to_le_bytes());
for _ in 0..8 {
body.extend_from_slice(&1i64.to_le_bytes());
}
}
let text = hex_encode(&body);
let result = decode_vitals(&text);
assert!(
result.is_err(),
"decoded {COUNT} vitals records with no record cap"
);
}

fn hex_encode(bytes: &[u8]) -> String {
const HEX: &[u8; 16] = b"0123456789abcdef";
let mut out = String::with_capacity(bytes.len() * 2);
for b in bytes {
out.push(HEX[(b >> 4) as usize] as char);
out.push(HEX[(b & 0x0f) as usize] as char);
}
out
}
18 changes: 18 additions & 0 deletions astraweave-llm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,24 @@ mod tests {
assert_eq!(plan.steps.len(), 4);
}

/// SEC-POC SEC-LLM-1. Constructors must refuse a non-loopback model URL.
/// `LocalHttpClient` speaks the chat-completions shape and stores whatever
/// string it is given, including a cloud host.
#[cfg(feature = "ollama")]
#[test]
fn poc_local_http_client_rejects_non_loopback_url() {
let client =
LocalHttpClient::new("https://api.openai.com".to_string(), "gpt-4".to_string());
let host = client.url.to_ascii_lowercase();
let loopback =
host.contains("127.0.0.1") || host.contains("localhost") || host.contains("[::1]");
assert!(
loopback,
"model client stored a non-loopback endpoint: {}",
client.url
);
}

#[cfg(feature = "ollama")]
#[test]
fn test_ollama_client_creation() {
Expand Down
15 changes: 15 additions & 0 deletions astraweave-scripting/tests/security_poc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! SEC-POC. See `docs/current/SECURITY_AUDIT.md` (SEC-MOD-4).

use astraweave_scripting::loader::ScriptLoader;

#[tokio::test]
async fn poc_script_loader_rejects_parent_segments() {
let err = ScriptLoader::load("../secret.rhai")
.await
.expect_err("hostile script path must not load");
let msg = format!("{err:#}");
assert!(
msg.to_lowercase().contains("traversal") || msg.to_lowercase().contains("rejected"),
"script path with parent segments was not rejected: {msg}"
);
}
Loading
Loading