{"record":{"id":"3783dc3611fc11f3","repo":"Hmbown/CodeWhale","slug":"codewhale-credentials-directory-cannot-be-a-volume","errorCode":null,"errorMessage":"Codewhale credentials directory cannot be a volume root","messagePattern":"Codewhale credentials directory cannot be a volume root","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/xai_credentials.rs","lineNumber":832,"sourceCode":"                    .read(true)\n                    .share_mode(FILE_SHARE_READ | FILE_SHARE_WRITE)\n                    .custom_flags(FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT);\n                let handle = options.open(&current).with_context(|| {\n                    format!(\n                        \"opening Codewhale credentials directory component {}\",\n                        crate::quote_os_path(&current)\n                    )\n                })?;\n                validate_windows_handle_path(&handle, &current, true)?;\n                handles.push(handle);\n            }\n            Component::CurDir | Component::ParentDir => bail!(\n                \"Codewhale credentials directory must be lexically normalized: {}\",\n                crate::quote_os_path(directory)\n            ),\n        }\n    }\n    anyhow::ensure!(\n        !handles.is_empty(),\n        \"Codewhale credentials directory cannot be a volume root\"\n    );\n    let mut secure_options = fs::OpenOptions::new();\n    secure_options\n        .access_mode(FILE_GENERIC_READ | WRITE_DAC | WRITE_OWNER)\n        .share_mode(FILE_SHARE_READ | FILE_SHARE_WRITE)\n        .custom_flags(FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT);\n    let final_directory = secure_options.open(directory).with_context(|| {\n        format!(\n            \"opening Codewhale credentials directory for owner-only security: {}\",\n            crate::quote_os_path(directory)\n        )\n    })?;\n    validate_windows_handle_path(&final_directory, directory, true)?;\n    secure_windows_owner_only_handle(&final_directory, true)\n        .context(\"securing Codewhale credentials directory for the current user\")?;\n    verify_windows_owner_only_handle(&final_directory)","sourceCodeStart":814,"sourceCodeEnd":850,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/config/src/xai_credentials.rs#L814-L850","documentation":"The windows opener keeps a validated non-delete-shared handle for every Normal path component; if there are none, the directory is a volume root (C:\\\\ or \\\\server\\\\share). A volume root cannot be given an owner-only DACL safely (it would lock the whole drive), so opening is refused. The public path always appends the `credentials` component, so this only fires for direct internal calls with a root path.","triggerScenarios":"Calling the private opener with Path::new(\"C:\\\\\") or a UNC root; refactors or tests that compute the credentials directory without appending a normal component.","commonSituations":"In-crate tests; refactors that collapse the derived path to a drive or UNC root through normalization.","solutions":["Ensure the directory path has at least one real component below the drive/UNC root (e.g. append `credentials`)","Use the public entry points, which always build $CODEWHALE_HOME/credentials"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"use std::path::Component;\n\nfn below_volume_root(p: &std::path::Path) -> bool {\n    p.components().any(|c| matches!(c, Component::Normal(_)))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always keep at least the `credentials` component under the drive/UNC root","Use public entry points that append the component for you","Reject CODEWHALE_HOME values that normalize to a bare drive root"],"tags":["windows","validation","filesystem","security","xai-oauth"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}