fix(solana): accept sysvars loaded from ALTs
What changed, and why it matters
This update fixes a bug in Trezor's Solana transaction handling. Some Solana transactions use a feature called 'address lookup tables' to save space, and Trezor was incorrectly rejecting valid transactions when a special system account (a 'sysvar') was referenced through one of these tables. The fix allows these references for most programs, but still blocks them for the Stake program because there the missing verification could shift account roles and cause confusion. The change is a functional bug fix rather than a clear-cut security patch, but it touches account validation rules that protect users from signing misleading transactions.
Treat this as a legitimate compatibility fix with a defensive carve-out. Review that the `allow_alt_sysvars=false` list covers every instruction where a sysvar is optional and followed by accounts whose roles could shift, and verify the generated `instructions.py` matches `programs.json`. Consider whether any other program beyond Stake has optional sysvars followed by meaningful accounts; if so, those instructions should also be set to false. No urgent security response is indicated by the commit alone.
Security signals we found
Change relaxes a previously strict validation rule (sysvar account identity verification) for some instruction types
Relaxation is scoped per-instruction via a new `allow_alt_sysvars` boolean
Stake program instructions retain strict rejection to prevent account-role shifting attacks
Fixes a real-world compatibility issue: Solana web3.js moves eligible accounts, including sysvars, into ALTs by default
No CVE, advisory, or independent researcher attribution present in the commit materials
Evidence from the diff
The commit modifies Trezor’s Solana instruction parser to accept sysvar accounts loaded from Address Lookup Tables (ALTs) for selected instructions. Previously, any sysvar reference that was an ALT index (an ‘address reference’) instead of a direct account caused a ValueError. The patch adds an allow_alt_sysvars flag per instruction: when true, ALT-based sysvar references are accepted without verifying the actual account; when false, the old strict behavior remains. The flag is set to false for all Stake program instructions because the Stake program treats sysvars as optional and reads the next account in that slot, so an unchecked ALT reference could shift subsequent accounts into unintended roles. For System, Token, Token-2022, and Associated Token Account programs the flag is set to true, relying on those programs either failing if the sysvar slot is wrong or having the sysvar as the last account. The change is enforced at code-generation time so every instruction with a sysvar reference must explicitly declare the policy.
Changed components
Trezor firmware Solana appcore/src/apps/solana/transaction/instruction.pycore/src/apps/solana/transaction/instructions.pycore/src/apps/solana/transaction/instructions.py.makocommon/defs/solana/programs.jsoncore/tests/test_apps.solana.transaction.pyInspect captured patch +100 / −6
### common/defs/solana/programs.json
@@ -192,6 +192,7 @@
"nonce_authority"
],
"references_required": 3,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"account": "nonce_account",
@@ -223,6 +224,7 @@
"nonce_authority"
],
"references_required": 5,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"parameter": "lamports",
@@ -260,6 +262,7 @@
"rent_sysvar"
],
"references_required": 3,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"account": "nonce_account",
@@ -516,6 +519,7 @@
"rent_sysvar"
],
"references_required": 2,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"account": "uninitialized_stake_account",
@@ -571,6 +575,7 @@
"lockup_authority"
],
"references_required": 3,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"account": "stake_account",
@@ -610,6 +615,7 @@
"stake_authority"
],
"references_required": 6,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"account": "initialized_stake_account",
@@ -683,6 +689,7 @@
"lockup_authority"
],
"references_required": 5,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"parameter": "lamports",
@@ -714,6 +721,7 @@
"stake_authority"
],
"references_required": 3,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"account": "delegated_stake_account",
@@ -792,6 +800,7 @@
"stake_authority"
],
"references_required": 5,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"account": "source_stake_account",
@@ -841,6 +850,7 @@
"lockup_authority"
],
"references_required": 3,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"account": "stake_account",
@@ -878,6 +888,7 @@
"withdrawal_authority"
],
"references_required": 4,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"account": "uninitialized_stake_account",
@@ -913,6 +924,7 @@
"lockup_authority"
],
"references_required": 4,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"account": "stake_account",
@@ -968,6 +980,7 @@
"lockup_authority"
],
"references_required": 4,
+ "allow_alt_sysvars": false,
"ui_properties": [
{
"account": "stake_account",
@@ -1131,6 +1144,7 @@
"rent_sysvar"
],
"references_required": 4,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"account": "account_to_initialize",
@@ -1162,6 +1176,7 @@
"rent_sysvar"
],
"references_required": 2,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"account": "multisig_account",
@@ -1681,6 +1696,7 @@
"rent_sysvar"
],
"references_required": 3,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"account": "account_to_initialize",
@@ -1778,6 +1794,7 @@
"rent_sysvar"
],
"references_required": 4,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"account": "account_to_initialize",
@@ -1809,6 +1826,7 @@
"rent_sysvar"
],
"references_required": 2,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"account": "multisig_account",
@@ -2329,6 +2347,7 @@
"rent_sysvar"
],
"references_required": 3,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"account": "account_to_initialize",
@@ -2429,6 +2448,7 @@
"rent_sysvar"
],
"references_required": 6,
+ "allow_alt_sysvars": true,
"ui_properties": [
{
"account": "associated_token_account",
### core/.changelog.d/8364.fixed
@@ -0,0 +1 @@
+Solana: Accept sysvar accounts loaded from address lookup tables, except in Stake program instructions.
### core/src/apps/solana/README.md
@@ -209,6 +209,7 @@ The `programs.json` file serves as a structured configuration file in the Solana
- `args`: An optional dict of arguments for the formatter, see explanation below.
- `references`: An array of account names that are used by the instruction. A reference named `*_sysvar` must hold the account listed under `sysvars`, otherwise the transaction is rejected.
- `references_required`: The number of references required by the instruction. If more `references` are specified than required, the extra ones are optional, and may or may not be present in the transaction.
+ - `allow_alt_sysvars`: Required for instructions with a `*_sysvar` reference, not allowed for the others. A boolean indicating whether such a reference may be loaded from an address lookup table, in which case the account can't be checked. With `false`, a transaction that does so is rejected. Set it to `false` for all instructions of a program whose sysvar accounts are optional, like the Stake program. Such a program reads a different account in the sysvar slot as the account that comes after the sysvars, which shifts the accounts that follow into roles other than the ones listed in `references`.
- `ui_properties`: Contains user interface-related information for this instruction.
- `account`: Reference to one account in the references list identified by its `name`
- `parameter`: Reference to one parameter in the parameters list identified by its `name`
### core/src/apps/solana/transaction/instruction.py
@@ -64,6 +64,7 @@ def parse_instruction_accounts(
accounts: list[Account],
accounts_required: int,
account_templates: tuple[str, ...],
+ allow_alt_sysvars: bool,
) -> dict[str, Account]:
from ..types import is_address_reference
from .instructions import SYSVAR_ACCOUNTS
@@ -77,10 +78,13 @@ def parse_instruction_accounts(
break
account = accounts[i]
sysvar = SYSVAR_ACCOUNTS.get(account_name)
- if sysvar is not None and (
- is_address_reference(account) or account[0] != sysvar
- ):
- raise ValueError # Sysvar slot does not hold the expected sysvar
+ if sysvar is not None:
+ if is_address_reference(account):
+ # The account loaded from the lookup table is unknown.
+ if not allow_alt_sysvars:
+ raise ValueError # Sysvar slot can't be verified
+ elif account[0] != sysvar:
+ raise ValueError # Sysvar slot does not hold the expected sysvar
parsed_accounts[account_name] = account
return parsed_accounts
@@ -101,6 +105,7 @@ def __init__(
supports_trailing_accounts: bool = False,
is_deprecated_warning: str | None = None,
trailing_accounts_warning: str | None = None,
+ allow_alt_sysvars: bool = False,
) -> None:
self.program_id = program_id
self.instruction_id = instruction_id
@@ -132,6 +137,7 @@ def __init__(
accounts,
accounts_required,
account_templates,
+ allow_alt_sysvars,
)
self.trailing_accounts = accounts[len(account_templates) :]
### core/src/apps/solana/transaction/instructions.py
@@ -1161,6 +1161,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_WITHDRAW_NONCE_ACCOUNT:
return Instruction(
@@ -1218,6 +1219,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_INITIALIZE_NONCE_ACCOUNT:
return Instruction(
@@ -1257,6 +1259,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_AUTHORIZE_NONCE_ACCOUNT:
return Instruction(
@@ -1651,6 +1654,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_AUTHORIZE:
return Instruction(
@@ -1720,6 +1724,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_DELEGATE_STAKE:
return Instruction(
@@ -1764,6 +1769,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_SPLIT:
return Instruction(
@@ -1873,6 +1879,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_DEACTIVATE:
return Instruction(
@@ -1904,6 +1911,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_SET_LOCKUP:
return Instruction(
@@ -2018,6 +2026,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_AUTHORIZE_WITH_SEED:
return Instruction(
@@ -2101,6 +2110,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_INITIALIZE_CHECKED:
return Instruction(
@@ -2143,6 +2153,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED:
return Instruction(
@@ -2206,6 +2217,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED_WITH_SEED:
return Instruction(
@@ -2283,6 +2295,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=False,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_SET_LOCKUP_CHECKED:
return Instruction(
@@ -2519,6 +2532,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_INITIALIZE_MULTISIG:
return Instruction(
@@ -2558,6 +2572,7 @@ def get_instruction(
True,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_TRANSFER:
return Instruction(
@@ -3251,6 +3266,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_SYNC_NATIVE:
return Instruction(
@@ -3399,6 +3415,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_MULTISIG:
return Instruction(
@@ -3438,6 +3455,7 @@ def get_instruction(
True,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_TRANSFER:
return Instruction(
@@ -4131,6 +4149,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_SYNC_NATIVE:
return Instruction(
@@ -4293,6 +4312,7 @@ def get_instruction(
False,
None,
None,
+ allow_alt_sysvars=True,
)
if instruction_id == _ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE_IDEMPOTENT:
return Instruction(
### core/src/apps/solana/transaction/instructions.py.mako
@@ -81,9 +81,15 @@ ${getProgramId(program)} = "${program["id"]}"
raise Exception(f"Sysvar \"{name}\" has an invalid account \"{sysvar}\".")
for program in programs["programs"]:
for instruction in program["instructions"]:
+ has_sysvar = False
for reference in instruction["references"]:
- if reference.endswith("_sysvar") and reference not in sysvars:
- raise Exception(f"Instruction \"{instruction['name']}\" references an unknown sysvar \"{reference}\".")
+ if reference.endswith("_sysvar"):
+ has_sysvar = True
+ if reference not in sysvars:
+ raise Exception(f"Instruction \"{instruction['name']}\" references an unknown sysvar \"{reference}\".")
+ # Whether a sysvar may be loaded from an address lookup table has to be decided for each instruction.
+ if has_sysvar != ("allow_alt_sysvars" in instruction):
+ raise Exception(f"Instruction \"{instruction['name']}\" must set \"allow_alt_sysvars\" if and only if it references a sysvar.")
%>
# Accounts that the `*_sysvar` references must hold.
SYSVAR_ACCOUNTS: dict[str, bytes] = {
@@ -253,6 +259,9 @@ def get_instruction(
${instruction["trailing_references"]},
${repr(instruction.get("is_deprecated_warning"))},
${repr(instruction.get("trailing_accounts_warning"))},
+ % if "allow_alt_sysvars" in instruction:
+ allow_alt_sysvars=${instruction["allow_alt_sysvars"]},
+ % endif
)
% endfor
return Instruction(
### core/tests/test_apps.solana.transaction.py
@@ -417,6 +417,13 @@ def test_v0_missing_alts(self):
# at index 3 and the signer as the stake authority.
DEACTIVATE_INSTRUCTION: RawInstruction = (2, (1, 3, 0), (5).to_bytes(4, "little"))
+TOKEN_PROGRAM = base58.decode("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
+TOKEN_ACCOUNT = b"k" * 32
+MINT = b"m" * 32
+# Initialize Account (instruction 1) at index 1 for the mint at index 2, with
+# the signer as the owner and the Rent sysvar at index 4.
+INITIALIZE_ACCOUNT_INSTRUCTION: RawInstruction = (3, (1, 2, 0, 4), b"\x01")
+
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestSolanaSysvarAccounts(unittest.TestCase):
@@ -458,6 +465,36 @@ def test_alt_reference(self):
)
)
+ def test_alt_reference_allowed(self):
+ # The Token program fails unless the Rent slot holds the sysvar, so the
+ # slot may refer to index 4, i.e. the address loaded from the table.
+ table = b"t" * 32
+ transaction = Transaction(
+ build_tx(
+ (1, 0, 2),
+ (SIGNER, TOKEN_ACCOUNT, MINT, TOKEN_PROGRAM),
+ [INITIALIZE_ACCOUNT_INSTRUCTION],
+ version=0,
+ alts=[(table, (), (7,))],
+ )
+ )
+ (initialize_account,) = transaction.instructions
+ self.assertEqual(
+ initialize_account.rent_sysvar, (table, 7, AddressType.AddressReadOnly)
+ )
+
+ def test_other_account_alt_reference_allowed(self):
+ # An account included in the transaction directly must be the sysvar
+ # even where an ALT reference is allowed.
+ with self.assertRaises(ValueError):
+ Transaction(
+ build_tx(
+ (1, 0, 3),
+ (SIGNER, TOKEN_ACCOUNT, MINT, TOKEN_PROGRAM, b"x" * 32),
+ [INITIALIZE_ACCOUNT_INSTRUCTION],
+ )
+ )
+
def raw_instructions(transaction: Transaction) -> list[tuple]:
# Instruction data are memoryviews, which can't be compared directly.Why this scored 50/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.