{"record":{"id":"d6694b37a0ce3799","repo":"astrid-runtime/astrid","slug":"mount-path-overflow","errorCode":null,"errorMessage":"mount path overflow","messagePattern":"mount path overflow","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/lib.rs","lineNumber":4409,"sourceCode":"    std::fs::File::open(path)?.sync_all()\n}\n\n#[cfg(target_os = \"linux\")]\nfn audit_mountpoint(path: &Path) -> std::io::Result<bool> {\n    use std::os::unix::ffi::OsStringExt as _;\n\n    let canonical = std::fs::canonicalize(path)?;\n    let mountinfo = std::fs::read_to_string(\"/proc/self/mountinfo\")?;\n    for line in mountinfo.lines() {\n        let Some(encoded) = line.split_whitespace().nth(4) else {\n            continue;\n        };\n        let mut decoded = Vec::with_capacity(encoded.len());\n        let bytes = encoded.as_bytes();\n        let mut index = 0;\n        while index < bytes.len() {\n            let escape_end = index.checked_add(4).ok_or_else(|| {\n                std::io::Error::new(std::io::ErrorKind::InvalidData, \"mount path overflow\")\n            })?;\n            let escape_start = index.checked_add(1).ok_or_else(|| {\n                std::io::Error::new(std::io::ErrorKind::InvalidData, \"mount path overflow\")\n            })?;\n            if bytes[index] == b'\\\\' && escape_end <= bytes.len() {\n                let digits = bytes.get(escape_start..escape_end).ok_or_else(|| {\n                    std::io::Error::new(std::io::ErrorKind::InvalidData, \"invalid mount escape\")\n                })?;\n                if digits.iter().all(|digit| (b'0'..=b'7').contains(digit)) {\n                    let value = u8::from_str_radix(\n                        std::str::from_utf8(digits).map_err(std::io::Error::other)?,\n                        8,\n                    )\n                    .map_err(std::io::Error::other)?;\n                    decoded.push(value);\n                    index = escape_end;\n                    continue;\n                }","sourceCodeStart":4391,"sourceCodeEnd":4427,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/lib.rs#L4391-L4427","documentation":"This InvalidData error guards the octal-escape decoder used to reconstruct mount path names. Before reading a 4-byte escape sequence it computes index+4 (and index+1) with checked arithmetic; on overflow it fails with 'mount path overflow' instead of wrapping. It also fires when a non-escape byte cannot advance the index by 1 without overflow.","triggerScenarios":"Decoding an encoded mount path whose byte index arithmetic would overflow usize — practically only on paths of astronomic length or on malformed index handling during decode_mount_path-style checks.","commonSituations":"Extremely large or corrupted encoded path strings passed to mount-path verification; adversarial input in a path-encoding field; 16-bit/32-bit platforms with tiny usize.","solutions":["Check the length of the encoded path input before decoding and reject absurdly long values","Ensure the caller passes a real filesystem path string, not arbitrary untrusted blobs","On 32-bit targets, run validation on 64-bit or bound inputs to < usize::MAX/4 bytes","If triggered by corrupt state, regenerate or repair the stored mount-path record"],"exampleFix":"// before\nlet decoded = decode_mount_path(untrusted_blob)?;\n// after\nif untrusted_blob.len() > 4096 { return Err(...) }\nlet decoded = decode_mount_path(untrusted_blob)?;","handlingStrategy":"validation","validationCode":"fn sane_len(s: &str) -> bool { s.len() < 4096 }\n// call only if sane_len(encoded_path)","typeGuard":null,"tryCatchPattern":"match decode_result {\n    Err(e) if e.to_string().contains(\"mount path overflow\") => eprintln!(\"input too large/corrupt\"),\n    other => other?,\n}","preventionTips":["Cap encoded path length before decoding","Only pass paths from canonicalize(), not arbitrary blobs","Never feed untrusted strings into the mount-path decoder"],"tags":["overflow","path-decoding","filesystem"],"backgroundTag":"invalid-argument-value","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}