{"answers":{"affected":"3 open source packages ship an affected version, including rust-crypto.","exploited":"There is no known exploitation of GHSA-jp3w-3q88-34cf in the wild and no public exploit code.","fix":"No fix has been published for GHSA-jp3w-3q88-34cf yet. Limit exposure of the affected software until one is available.","what":"GHSA-jp3w-3q88-34cf is a vulnerability in rust-crypto, published on 28 Feb 2022."},"fix_prompt":"Check this codebase for GHSA-jp3w-3q88-34cf and fix it if it is affected.\n\nWhat it is: GHSA-jp3w-3q88-34cf is a vulnerability in rust-crypto, published on 28 Feb 2022. \nExploitation: There is no known exploitation of GHSA-jp3w-3q88-34cf in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- rust-crypto (crates.io): affected all versions up to 0.2.36; no fix listed\n- rust-crypto (crates.io): affected all versions up to 0.2.36; no fix listed\n- rust-crypto (crates.io): affected from 0.0.0-0; no fix listed\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-jp3w-3q88-34cf/ (Markdown: https://insights.sbomify.com/GHSA-jp3w-3q88-34cf/index.md)","id":"GHSA-jp3w-3q88-34cf","markdown":"https://insights.sbomify.com/GHSA-jp3w-3q88-34cf/index.md","name":"GHSA-jp3w-3q88-34cf","record":{"aliases":["RUSTSEC-2022-0011"],"analysis":{"component_type":"library","fix_type":"upgrade","impacts":["other"],"network_reachable":"unknown","non_default_config":false,"product_category":"Rust crypto library","requires_auth":"none","summary":"Incorrect AES key expansion causes inconsistent encryption results, potentially leading to data integrity issues or failed decryption in applications using rust-crypto.","user_interaction":"not_required","vuln_class":"weak_cryptography"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"The following Rust program demonstrates some strangeness in AES encryption - if you have an immutable key slice and then operate on that slice, you get different encryption output than if you operate on a copy of that key.\n\nFor these functions, we expect that extending a 16 byte key to a 32 byte key by repeating it gives the same encrypted data, because the underlying rust-crypto functions repeat key data up to the necessary key size for the cipher.\n\n```rust\nuse crypto::{\n    aes, blockmodes, buffer,\n    buffer::{BufferResult, ReadBuffer, WriteBuffer},\n    symmetriccipher,\n};\n\nfn encrypt(\n    key: \u0026[u8],\n    iv: \u0026[u8],\n    data: \u0026str,\n) -\u003e Result\u003cString, symmetriccipher::SymmetricCipherError\u003e {\n    let mut encryptor =\n        aes::cbc_encryptor(aes::KeySize::KeySize256, key, iv, blockmodes::PkcsPadding);\n\n    let mut encrypted_data = Vec::\u003cu8\u003e::new();\n    let mut read_buffer = buffer::RefReadBuffer::new(data.as_bytes());\n    let mut buffer = [0; 4096];\n    let mut write_buffer = buffer::RefWriteBuffer::new(\u0026mut buffer);\n\n    loop {\n        let result = encryptor.encrypt(\u0026mut read_buffer, \u0026mut write_buffer, true)?;\n\n        encrypted_data.extend(\n            write_buffer\n                .take_read_buffer()\n                .take_remaining()\n                .iter()\n                .copied(),\n        );\n\n        match result {\n            BufferResult::BufferUnderflow =\u003e break,\n            BufferResult::BufferOverflow =\u003e {}\n        }\n    }\n\n    Ok(hex::encode(encrypted_data))\n}\n\nfn working() {\n    let data = \"data\";\n    let iv = [\n        0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE,\n        0xFF,\n    ];\n    let key = [\n        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,\n        0x0F,\n    ];\n    // The copy here makes the code work.\n    let key_copy = key;\n    let key2: Vec\u003cu8\u003e = key_copy.iter().cycle().take(32).copied().collect();\n    println!(\"key1:{} key2: {}\", hex::encode(\u0026key), hex::encode(\u0026key2));\n\n    let x1 = encrypt(\u0026key, \u0026iv, data).unwrap();\n    println!(\"X1: {}\", x1);\n\n    let x2 = encrypt(\u0026key2, \u0026iv, data).unwrap();\n    println!(\"X2: {}\", x2);\n\n    assert_eq!(x1, x2);\n}\n\nfn broken() {\n    let data = \"data\";\n    let iv = [\n        0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE,\n        0xFF,\n    ];\n    let key = [\n        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,\n        0x0F,\n    ];\n    // This operation shouldn't affect the contents of key at all.\n    let key2: Vec\u003cu8\u003e = key.iter().cycle().take(32).copied().collect();\n    println!(\"key1:{} key2: {}\", hex::encode(\u0026key), hex::encode(\u0026key2));\n\n    let x1 = encrypt(\u0026key, \u0026iv, data).unwrap();\n    println!(\"X1: {}\", x1);\n\n    let x2 = encrypt(\u0026key2, \u0026iv, data).unwrap();\n    println!(\"X2: {}\", x2);\n\n    assert_eq!(x1, x2);\n}\n\nfn main() {\n    working();\n    broken();\n}\n```\n\nThe output from this program:\n\n```shell\n     Running `target/host/debug/rust-crypto-test`\nkey1:000102030405060708090a0b0c0d0e0f key2: 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f\nX1: 90462bbe32965c8e7ea0addbbed4cddb\nX2: 90462bbe32965c8e7ea0addbbed4cddb\nkey1:000102030405060708090a0b0c0d0e0f key2: 000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f\nX1: 26e847e5e7df1947bf82a650548a7d5b\nX2: 90462bbe32965c8e7ea0addbbed4cddb\nthread 'main' panicked at 'assertion failed: `(left == right)`\n  left: `\"26e847e5e7df1947bf82a650548a7d5b\"`,\n right: `\"90462bbe32965c8e7ea0addbbed4cddb\"`', src/main.rs:83:5\n```\n\nNotably, the X1 key in the `broken()` test changes every time after rerunning the program.","ecosystems":["crates.io"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":false,"headline":"Miscomputation when performing AES encryption in rust-crypto","id":"GHSA-jp3w-3q88-34cf","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"crates.io","product":null,"products":[],"type":"weak_cryptography","year":"2022"},"n_packages":3,"n_references":null,"packages":[{"ecosystem":"crates.io","fixed":[],"introduced":["0"],"last_affected":["0.2.36"],"package":"rust-crypto","purl":null,"source":"GHSA-jp3w-3q88-34cf"},{"ecosystem":"crates.io","fixed":[],"introduced":["0"],"last_affected":["0.2.36"],"package":"rust-crypto","purl":"pkg:cargo/rust-crypto","source":"GHSA-jp3w-3q88-34cf"},{"ecosystem":"crates.io","fixed":[],"introduced":["0.0.0-0"],"last_affected":[],"package":"rust-crypto","purl":"pkg:cargo/rust-crypto","source":"RUSTSEC-2022-0011"}],"products":null,"published":"2022-02-28","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"},{"class":"open","licence":"CC0 1.0","name":"RustSec","prefix":"RUSTSEC"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Incorrect AES key expansion causes inconsistent encryption results, potentially leading to data integrity issues or failed decryption in applications using rust-crypto.","url":"https://insights.sbomify.com/GHSA-jp3w-3q88-34cf/"}