{"id":"CVE-2024-36400","aliases":["CVE-2024-36400","GHSA-2hfw-w739-p7x5","GHSA-9hc7-6w9r-wj94","RUSTSEC-2024-0343"],"related":[],"kind":"vulnerability","state":"published","title":"nano-id is unable to generate the correct character set","summary":"nano-id is a unique string ID generator for Rust. Affected versions of the nano-id crate incorrectly generated IDs using a reduced character set in the `nano_id::base62` and `nano_id::base58` functions. Specifically, the `base62` function used a character set of 32 symbols instead of the intended 62 symbols, and the `base58` function used a character set of 16 symbols instead of the intended 58 symbols. Additionally, the `nano_id::gen` macro is also affected when a custom character set that is not a power of 2 in size is specified. It should be noted that `nano_id::base64` is not affected by this vulnerability. This can result in a significant reduction in entropy, making the generated IDs predictable and vulnerable to brute-force attacks when the IDs are used in security-sensitive contexts such as session tokens or unique identifiers. The vulnerability is fixed in 0.4.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"nano-id is a unique string ID generator for Rust. Affected versions of the nano-id crate incorrectly generated IDs using a reduced character set in the `nano_id::base62` and `nano_id::base58` functions. Specifically, the `base62` function used a character set of 32 symbols instead of the intended 62 symbols, and the `base58` function used a character set of 16 symbols instead of the intended 58 symbols. Additionally, the `nano_id::gen` macro is also affected when a custom character set that is not a power of 2 in size is specified. It should be noted that `nano_id::base64` is not affected by this vulnerability. This can result in a significant reduction in entropy, making the generated IDs predictable and vulnerable to brute-force attacks when the IDs are used in security-sensitive contexts such as session tokens or unique identifiers. The vulnerability is fixed in 0.4.0.","source":"cvelist"},{"lang":"en","text":"## Duplicate Advisory\nThis advisory has been withdrawn because it is a duplicate of GHSA-9hc7-6w9r-wj94. This link is maintained to preserve external references.\n\n## Original Description\n## Description\n\nAffected versions of the nano-id crate incorrectly generated IDs using a reduced character set in the `nano_id::base62` and `nano_id::base58` functions. Specifically, the `base62` function used a character set of 32 symbols instead of the intended 62 symbols, and the `base58` function used a character set of 16 symbols instead of the intended 58 symbols. Additionally, the `nano_id::gen` macro is also affected when a custom character set that is not a power of 2 in size is specified.\n\nIt should be noted that `nano_id::base64` is not affected by this vulnerability.\n\n## Impact\n\nThis can result in a significant reduction in entropy, making the generated IDs predictable and vulnerable to brute-force attacks when the IDs are used in security-sensitive contexts such as session tokens or unique identifiers.\n\n## Patches\n\nThe flaws were corrected in commit [a9022772b2f1ce38929b5b81eccc670ac9d3ab23](https://github.com/viz-rs/nano-id/commit/a9022772b2f1ce38929b5b81eccc670ac9d3ab23) by updating the the `nano_id::gen` macro to use all specified characters correctly.\n\n## PoC\n\n```rust\nuse std::collections::BTreeSet;\n\nfn main() {\n    test_base58();\n    test_base62();\n}\n\nfn test_base58() {\n    let mut produced_symbols = BTreeSet::new();\n\n    for _ in 0..100_000 {\nid = \"RUSTSEC-2024-0343\"\n        for c in id.chars() {\n            produced_symbols.insert(c);\n        }\n    }\n\n    println!(\n        \"{} symbols generated from nano_id::base58\",\n        produced_symbols.len()\n    );\n}\n\nfn test_base62() {\n    let mut produced_symbols = BTreeSet::new();\n\n    for _ in 0..100_000 {\nid = \"RUSTSEC-2024-0343\"\n        for c in id.chars() {\n            produced_symbols.insert(c);\n        }\n    }\n\n    println!(\n        \"{} symbols generated from nano_id::base62\",\n        produced_symbols.len()\n    );\n}\n```","format":"markdown","source":"ghsa"},{"lang":"en","text":"# Reduced entropy due to inadequate character set usage\n\n## Description\n\nAffected versions of the nano-id crate incorrectly generated IDs using a reduced character set in the `nano_id::base62` and `nano_id::base58` functions. Specifically, the `base62` function used a character set of 32 symbols instead of the intended 62 symbols, and the `base58` function used a character set of 16 symbols instead of the intended 58 symbols. Additionally, the `nano_id::gen` macro is also affected when a custom character set that is not a power of 2 in size is specified.\n\nIt should be noted that `nano_id::base64` is not affected by this vulnerability.\n\n## Impact\n\nThis can result in a significant reduction in entropy, making the generated IDs predictable and vulnerable to brute-force attacks when the IDs are used in security-sensitive contexts such as session tokens or unique identifiers.\n\n## Patches\n\nThe flaws were corrected in commit [a9022772b2f1ce38929b5b81eccc670ac9d3ab23](https://github.com/viz-rs/nano-id/commit/a9022772b2f1ce38929b5b81eccc670ac9d3ab23) by updating the the `nano_id::gen` macro to use all specified characters correctly.\n\n## PoC\n\n```rust\nuse std::collections::BTreeSet;\n\nfn main() {\n    test_base58();\n    test_base62();\n}\n\nfn test_base58() {\n    let mut produced_symbols = BTreeSet::new();\n\n    for _ in 0..100_000 {\n        let id = nano_id::base58::<10>();\n        for c in id.chars() {\n            produced_symbols.insert(c);\n        }\n    }\n\n    println!(\n        \"{} symbols generated from nano_id::base58\",\n        produced_symbols.len()\n    );\n}\n\nfn test_base62() {\n    let mut produced_symbols = BTreeSet::new();\n\n    for _ in 0..100_000 {\n        let id = nano_id::base62::<10>();\n        for c in id.chars() {\n            produced_symbols.insert(c);\n        }\n    }\n\n    println!(\n        \"{} symbols generated from nano_id::base62\",\n        produced_symbols.len()\n    );\n}\n```","format":"markdown","source":"ghsa"},{"lang":"en","text":"## Description\n\nAffected versions of the nano-id crate incorrectly generated IDs using a reduced character set in the `nano_id::base62` and `nano_id::base58` functions. Specifically, the `base62` function used a character set of 32 symbols instead of the intended 62 symbols, and the `base58` function used a character set of 16 symbols instead of the intended 58 symbols. Additionally, the `nano_id::gen` macro is also affected when a custom character set that is not a power of 2 in size is specified.\n\nIt should be noted that `nano_id::base64` is not affected by this vulnerability.\n\n## Impact\n\nThis can result in a significant reduction in entropy, making the generated IDs predictable and vulnerable to brute-force attacks when the IDs are used in security-sensitive contexts such as session tokens or unique identifiers.\n\n## Patches\n\nThe flaws were corrected in commit [a9022772b2f1ce38929b5b81eccc670ac9d3ab23](https://github.com/viz-rs/nano-id/commit/a9022772b2f1ce38929b5b81eccc670ac9d3ab23) by updating the the `nano_id::gen` macro to use all specified characters correctly.\n\n## PoC\n\n```rust\nuse std::collections::BTreeSet;\n\nfn main() {\n    test_base58();\n    test_base62();\n}\n\nfn test_base58() {\n    let mut produced_symbols = BTreeSet::new();\n\n    for _ in 0..100_000 {\nid = \"RUSTSEC-2024-0343\"\n        for c in id.chars() {\n            produced_symbols.insert(c);\n        }\n    }\n\n    println!(\n        \"{} symbols generated from nano_id::base58\",\n        produced_symbols.len()\n    );\n}\n\nfn test_base62() {\n    let mut produced_symbols = BTreeSet::new();\n\n    for _ in 0..100_000 {\nid = \"RUSTSEC-2024-0343\"\n        for c in id.chars() {\n            produced_symbols.insert(c);\n        }\n    }\n\n    println!(\n        \"{} symbols generated from nano_id::base62\",\n        produced_symbols.len()\n    );\n}\n```","format":"markdown","source":"rustsec"},{"lang":"es","text":"nano-id es un generador de ID de cadena único para Rust. Las versiones afectadas de la caja nano-id generaron identificaciones incorrectamente utilizando un conjunto de caracteres reducido en las funciones `nano_id::base62` y `nano_id::base58`. Específicamente, la función \"base62\" usó un conjunto de caracteres de 32 símbolos en lugar de los 62 símbolos previstos, y la función \"base58\" usó un conjunto de caracteres de 16 símbolos en lugar de los 58 símbolos previstos. Además, la macro `nano_id::gen` también se ve afectada cuando se especifica un conjunto de caracteres personalizado que no tiene un tamaño de potencia de 2. Cabe señalar que `nano_id::base64` no se ve afectado por esta vulnerabilidad. Esto puede dar como resultado una reducción significativa de la entropía, lo que hace que los ID generados sean predecibles y vulnerables a ataques de fuerza bruta cuando los ID se utilizan en contextos sensibles a la seguridad, como tokens de sesión o identificadores únicos. La vulnerabilidad se solucionó en 0.4.0.","source":"nvd"}],"published":"2024-06-03T12:00:00.000Z","modified":"2026-09-10T03:50:15.085Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L","score":9.4,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L","score":9.4,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L","score":9.4,"rating":"CRITICAL"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L","score":9.4,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-331"],"affected":[{"ranges":[{"version":"< 0.4.0","status":"affected"}],"vendor":"viz-rs","product":"nano-id","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","fixed":"0.4.0","status":"affected"}],"vendor":"viz-rs","product":"nano-id","cpe":"cpe:2.3:a:viz-rs:nano-id:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.4.0"}],"ecosystem":"crates.io","package":"nano-id","purl":"pkg:cargo/nano-id","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.4.0"}],"ecosystem":"crates.io","package":"nano-id","purl":"pkg:cargo/nano-id","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0.0.0-0","status":"affected","fixed":"0.4.0"}],"ecosystem":"crates.io","package":"nano-id","purl":"pkg:cargo/nano-id","source":"rustsec"},{"ranges":[{"status":"affected","fixed":"0.4.0"}],"vendor":"viz","product":"nano_id","cpe":"cpe:2.3:a:viz:nano_id:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://github.com/viz-rs/nano-id/security/advisories/GHSA-9hc7-6w9r-wj94","tags":["exploit","patch","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/viz-rs/nano-id/commit/a9022772b2f1ce38929b5b81eccc670ac9d3ab23","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/viz-rs/nano-id","tags":["package"],"sources":["ghsa"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2024-0343.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-36400","tags":["advisory"],"sources":["ghsa"]},{"url":"https://crates.io/crates/nano-id","tags":["package"],"sources":["rustsec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"total","date":"2024-06-04T15:30:53.603Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-36400","url":"https://www.cve.org/CVERecord?id=CVE-2024-36400","licence":"CVE Terms of Use","modified":"2024-08-02T03:37:05.234Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2hfw-w739-p7x5","url":"https://github.com/advisories/GHSA-2hfw-w739-p7x5","licence":"CC-BY-4.0","modified":"2026-02-03T17:49:49.768Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-9hc7-6w9r-wj94","url":"https://github.com/advisories/GHSA-9hc7-6w9r-wj94","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:15.085Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2024-0343","url":"https://rustsec.org/advisories/RUSTSEC-2024-0343.html","licence":"CC0-1.0","modified":"2024-06-15T13:27:23.912Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-36400","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-36400","licence":"Public domain","modified":"2026-06-17T07:36:38.703Z"}],"updatedAt":"2026-11-25T22:58:41.425Z","epss":{"score":0.00754,"percentile":0.56296,"date":"2026-12-01T12:00:22.000Z"}}