feat(solana): warn about hooks on Transfer Checked with trailing accounts
What changed, and why it matters
This commit adds a new on-screen warning for Trezor users when they are about to sign a specific Solana token transfer that includes extra accounts. Those extra accounts can mean a third-party 'transfer hook' program is triggered, potentially adding hidden fees or restrictions. The change is a user-interface improvement to prevent users from unknowingly approving such transfers, not a fix for a code execution bug in Trezor itself.
Users should ensure firmware is updated so they receive the new warning. Developers should consider whether further hardening is needed, such as requiring explicit opt-in for transfer-hook-bearing transfers or validating that trailing accounts match expected hook program accounts, because this patch only warns and does not prevent signing.
Security signals we found
New user-facing warning for third-party program invocation
Token-2022 transfer hook extension behavior acknowledged
UI-only mitigation; no enforcement or validation of hook accounts
Partial fix for issue #325 (informational layer only)
Changelog entry tagged as security-relevant
Evidence from the diff
The patch introduces a trailing_accounts_warning field in Solana instruction definitions and displays it during transaction confirmation. It is applied only to Token-2022 Transfer Checked (instruction id 12) when trailing accounts are present. Token-2022 mints may include the transfer hook extension, which causes a CPI to a hook program whose accounts are appended after the standard signers. Without this warning, the user would see only the extra account list and not be told a third-party program may run. The change is purely informational: it does not block, validate, or alter the transaction, and it does not inspect the hook program.
Changed components
Trezor firmware Solana appcommon/defs/solana/programs.jsoncore/src/apps/solana/layout.pycore/src/apps/solana/transaction/instruction.pycore/src/apps/solana/transaction/instructions.pycore/src/apps/solana/transaction/instructions.py.makoInspect captured patch +141 / −0
### common/defs/solana/programs.json
@@ -2118,6 +2118,7 @@
"id": 12,
"name": "Transfer Checked",
"trailing_references": true,
+ "trailing_accounts_warning": "This transfer may invoke the token's transfer hook program. Additional restrictions or fees may apply.",
"parameters": [
{
"name": "amount",
### common/tests/fixtures/solana/sign_tx.token_2022_program.json
@@ -0,0 +1,53 @@
+{
+ "setup": {
+ "mnemonic": "all all all all all all all all all all all all",
+ "passphrase": ""
+ },
+ "tests": [
+ {
+ "description": "Transfer Checked - Transfer Hook",
+ "parameters": {
+ "address": "m/44'/501'/0'/0'",
+ "construct": {
+ "version": null,
+ "header": {
+ "signers": 1,
+ "readonly_signers": 0,
+ "readonly_non_signers": 4
+ },
+ "accounts": [
+ "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
+ "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF",
+ "FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX",
+ "6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK",
+ "ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
+ "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq",
+ "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
+ ],
+ "blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
+ "instructions": [
+ {
+ "program_index": 6,
+ "accounts": {
+ "source_account": 2,
+ "token_mint": 3,
+ "destination_account": 1,
+ "owner": 0,
+ "trailing_accounts": [4, 5]
+ },
+ "data": {
+ "instruction_id": 12,
+ "amount": 200,
+ "decimals": 1
+ }
+ }
+ ],
+ "luts": []
+ }
+ },
+ "result": {
+ "expected_signature": "5d843b9a12fe3db64cd64a53b8fe2ed790a1aff2d9db2ba88b4dcb05e836be03e8d6d0834d23a34f5f2bdb1b555c24a88d9637c095d14d358bfd39151f8be00b"
+ }
+ }
+ ]
+}
### core/.changelog.d/+solana_transfer_hooks.security
@@ -0,0 +1 @@
+Solana: Warn about a possible transfer hook in Token-2022 Transfer Checked instructions with trailing accounts.
### core/src/apps/solana/README.md
@@ -201,6 +201,7 @@ The `programs.json` file serves as a structured configuration file in the Solana
- `name`: The name of the instruction, providing a human-readable label.
- `trailing_references`: A boolean indicating whether the instruction accepts additional account references beyond those listed in `references` (e.g. multisig signers for Token program instructions, or the accounts of a newly created multisig).
- `is_deprecated_warning`: Optional, contains a warning message when the instruction is deprecated
+ - `trailing_accounts_warning`: Optional, contains a warning message shown when the instruction carries trailing account references (e.g. Token-2022 `Transfer Checked`, whose trailing accounts may belong to a transfer hook program)
- `parameters`: Describes the parameters required for this instruction.
- `name`: The parameter name.
- `type`: The data type of the parameter, such as `u64` for 64-bit unsigned integers.
### core/src/apps/solana/layout.py
@@ -167,6 +167,14 @@ async def confirm_instruction(
raise ValueError # Invalid ui property
if instruction.trailing_accounts:
+ if instruction.trailing_accounts_warning is not None:
+ await confirm_metadata(
+ "confirm_trailing_accounts_warning",
+ instruction_full_title,
+ instruction.trailing_accounts_warning,
+ br_code=ButtonRequestType.Other,
+ )
+
trailing_account_props: list[StrPropertyType] = []
for i, trailing_account in enumerate(instruction.trailing_accounts, 1):
trailing_account_props += _get_account_props(
### core/src/apps/solana/transaction/instruction.py
@@ -32,6 +32,7 @@ class Instruction:
trailing_accounts: list[Account]
is_deprecated_warning: str | None = None
+ trailing_accounts_warning: str | None = None
@staticmethod
def parse_instruction_data(
@@ -90,6 +91,7 @@ def __init__(
is_ui_hidden: bool = False,
supports_trailing_accounts: bool = False,
is_deprecated_warning: str | None = None,
+ trailing_accounts_warning: str | None = None,
) -> None:
self.program_id = program_id
self.instruction_id = instruction_id
@@ -107,6 +109,7 @@ def __init__(
self.is_instruction_supported = is_instruction_supported
self.is_deprecated_warning = is_deprecated_warning
+ self.trailing_accounts_warning = trailing_accounts_warning
self.instruction_data = instruction_data
self.accounts = accounts
### core/src/apps/solana/transaction/instructions.py
@@ -945,6 +945,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_ASSIGN:
return Instruction(
@@ -983,6 +984,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_TRANSFER:
return Instruction(
@@ -1027,6 +1029,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_CREATE_ACCOUNT_WITH_SEED:
return Instruction(
@@ -1111,6 +1114,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_ADVANCE_NONCE_ACCOUNT:
return Instruction(
@@ -1141,6 +1145,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_WITHDRAW_NONCE_ACCOUNT:
return Instruction(
@@ -1197,6 +1202,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_INITIALIZE_NONCE_ACCOUNT:
return Instruction(
@@ -1235,6 +1241,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_AUTHORIZE_NONCE_ACCOUNT:
return Instruction(
@@ -1279,6 +1286,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_ALLOCATE:
return Instruction(
@@ -1317,6 +1325,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_ALLOCATE_WITH_SEED:
return Instruction(
@@ -1382,6 +1391,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_ASSIGN_WITH_SEED:
return Instruction(
@@ -1434,6 +1444,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_TRANSFER_WITH_SEED:
return Instruction(
@@ -1492,6 +1503,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _SYSTEM_PROGRAM_ID_INS_UPGRADE_NONCE_ACCOUNT:
return Instruction(
@@ -1516,6 +1528,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
return Instruction(
instruction_data,
@@ -1622,6 +1635,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_AUTHORIZE:
return Instruction(
@@ -1690,6 +1704,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_DELEGATE_STAKE:
return Instruction(
@@ -1733,6 +1748,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_SPLIT:
return Instruction(
@@ -1783,6 +1799,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_WITHDRAW:
return Instruction(
@@ -1840,6 +1857,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_DEACTIVATE:
return Instruction(
@@ -1870,6 +1888,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_SET_LOCKUP:
return Instruction(
@@ -1940,6 +1959,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_MERGE:
return Instruction(
@@ -1982,6 +2002,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_AUTHORIZE_WITH_SEED:
return Instruction(
@@ -2064,6 +2085,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_INITIALIZE_CHECKED:
return Instruction(
@@ -2105,6 +2127,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED:
return Instruction(
@@ -2167,6 +2190,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_AUTHORIZE_CHECKED_WITH_SEED:
return Instruction(
@@ -2243,6 +2267,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _STAKE_PROGRAM_ID_INS_SET_LOCKUP_CHECKED:
return Instruction(
@@ -2310,6 +2335,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
return Instruction(
instruction_data,
@@ -2358,6 +2384,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_LIMIT:
return Instruction(
@@ -2390,6 +2417,7 @@ def get_instruction(
True,
False,
None,
+ None,
)
if instruction_id == _COMPUTE_BUDGET_PROGRAM_ID_INS_SET_COMPUTE_UNIT_PRICE:
return Instruction(
@@ -2422,6 +2450,7 @@ def get_instruction(
True,
False,
None,
+ None,
)
return Instruction(
instruction_data,
@@ -2474,6 +2503,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_INITIALIZE_MULTISIG:
return Instruction(
@@ -2512,6 +2542,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_TRANSFER:
return Instruction(
@@ -2562,6 +2593,7 @@ def get_instruction(
False,
True,
"Warning: Instruction is deprecated. Token decimals unknown.",
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_APPROVE:
return Instruction(
@@ -2612,6 +2644,7 @@ def get_instruction(
False,
True,
"Warning: Instruction is deprecated. Token decimals unknown.",
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_REVOKE:
return Instruction(
@@ -2642,6 +2675,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_SET_AUTHORITY:
return Instruction(
@@ -2699,6 +2733,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_MINT_TO:
return Instruction(
@@ -2749,6 +2784,7 @@ def get_instruction(
False,
True,
"Warning: Instruction is deprecated. Token decimals unknown.",
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_BURN:
return Instruction(
@@ -2799,6 +2835,7 @@ def get_instruction(
False,
True,
"Warning: Instruction is deprecated. Token decimals unknown.",
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_CLOSE_ACCOUNT:
return Instruction(
@@ -2835,6 +2872,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_FREEZE_ACCOUNT:
return Instruction(
@@ -2871,6 +2909,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_THAW_ACCOUNT:
return Instruction(
@@ -2907,6 +2946,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_TRANSFER_CHECKED:
return Instruction(
@@ -2970,6 +3010,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_APPROVE_CHECKED:
return Instruction(
@@ -3033,6 +3074,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_MINT_TO_CHECKED:
return Instruction(
@@ -3090,6 +3132,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_BURN_CHECKED:
return Instruction(
@@ -3147,6 +3190,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_2:
return Instruction(
@@ -3191,6 +3235,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_SYNC_NATIVE:
return Instruction(
@@ -3215,6 +3260,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3:
return Instruction(
@@ -3259,6 +3305,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _TOKEN_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER:
return Instruction(
@@ -3283,6 +3330,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
return Instruction(
instruction_data,
@@ -3335,6 +3383,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_MULTISIG:
return Instruction(
@@ -3373,6 +3422,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_TRANSFER:
return Instruction(
@@ -3423,6 +3473,7 @@ def get_instruction(
False,
True,
"Warning: Instruction is deprecated. Token decimals unknown.",
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_APPROVE:
return Instruction(
@@ -3473,6 +3524,7 @@ def get_instruction(
False,
True,
"Warning: Instruction is deprecated. Token decimals unknown.",
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_REVOKE:
return Instruction(
@@ -3503,6 +3555,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_SET_AUTHORITY:
return Instruction(
@@ -3560,6 +3613,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_MINT_TO:
return Instruction(
@@ -3610,6 +3664,7 @@ def get_instruction(
False,
True,
"Warning: Instruction is deprecated. Token decimals unknown.",
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_BURN:
return Instruction(
@@ -3660,6 +3715,7 @@ def get_instruction(
False,
True,
"Warning: Instruction is deprecated. Token decimals unknown.",
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_CLOSE_ACCOUNT:
return Instruction(
@@ -3696,6 +3752,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_FREEZE_ACCOUNT:
return Instruction(
@@ -3732,6 +3789,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_THAW_ACCOUNT:
return Instruction(
@@ -3768,6 +3826,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_TRANSFER_CHECKED:
return Instruction(
@@ -3831,6 +3890,7 @@ def get_instruction(
False,
True,
None,
+ "This transfer may invoke the token's transfer hook program. Additional restrictions or fees may apply.",
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_APPROVE_CHECKED:
return Instruction(
@@ -3894,6 +3954,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_MINT_TO_CHECKED:
return Instruction(
@@ -3951,6 +4012,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_BURN_CHECKED:
return Instruction(
@@ -4008,6 +4070,7 @@ def get_instruction(
False,
True,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_2:
return Instruction(
@@ -4052,6 +4115,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_SYNC_NATIVE:
return Instruction(
@@ -4076,6 +4140,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_ACCOUNT_3:
return Instruction(
@@ -4120,6 +4185,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _TOKEN_2022_PROGRAM_ID_INS_INITIALIZE_IMMUTABLE_OWNER:
return Instruction(
@@ -4144,6 +4210,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
return Instruction(
instruction_data,
@@ -4210,6 +4277,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_CREATE_IDEMPOTENT:
return Instruction(
@@ -4259,6 +4327,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
if instruction_id == _ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID_INS_RECOVER_NESTED:
return Instruction(
@@ -4303,6 +4372,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
return Instruction(
instruction_data,
@@ -4357,6 +4427,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
return Instruction(
instruction_data,
@@ -4411,6 +4482,7 @@ def get_instruction(
False,
False,
None,
+ None,
)
return Instruction(
instruction_data,
### core/src/apps/solana/transaction/instructions.py.mako
@@ -229,6 +229,7 @@ def get_instruction(
${instruction.get("is_ui_hidden", False)},
${instruction["trailing_references"]},
${repr(instruction.get("is_deprecated_warning"))},
+ ${repr(instruction.get("trailing_accounts_warning"))},
)
% endfor
return Instruction(
### tests/device_tests/solana/test_sign_tx.py
@@ -57,6 +57,7 @@ def get_amount_and_destination(parameters, instruction):
"solana/sign_tx.memo_program.json",
"solana/sign_tx.compute_budget_program.json",
"solana/sign_tx.token_program.json",
+ "solana/sign_tx.token_2022_program.json",
"solana/sign_tx.unknown_instructions.json",
"solana/sign_tx.predefined_transactions.json",
"solana/sign_tx.staking_transactions.json",Why this scored 51/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.