Skip to content

Commit 09abc1f

Browse files
Merge pull request #628 from LedgerHQ/fix/apa/blind_signing_app_policies
Rework blind signing policies
2 parents 4a21b8a + 7713ee0 commit 09abc1f

File tree

180 files changed

+325
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+325
-252
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [1.11.2](https://github.com/ledgerhq/app-ethereum/compare/1.11.1...1.11.2) - 2024-08-13
9+
10+
### Added
11+
12+
- Blind-signing setting
13+
14+
### Changed
15+
16+
- Simplified blind-signing warnings on Flex & Stax
17+
- Restored blind-signing warning screen from < 1.11.0 on Nano devices
18+
819
## [1.11.1](https://github.com/ledgerhq/app-ethereum/compare/1.11.0...1.11.1) - 2024-07-26
920

1021
### Fixed
@@ -38,6 +49,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3849
- Ledger Flex support
3950

4051
### Removed
52+
4153
- (clone) Flare
4254
- (clone) Flare Coston
4355
- (clone) Eth Goerli

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ include ./makefile_conf/chain/$(CHAIN).mk
3939

4040
APPVERSION_M = 1
4141
APPVERSION_N = 11
42-
APPVERSION_P = 1
42+
APPVERSION_P = 2
4343
APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
4444

4545
# Application source files
@@ -156,7 +156,6 @@ DISABLE_STANDARD_APP_FILES = 1
156156
########################################
157157

158158
DEFINES += CHAINID_COINNAME=\"$(TICKER)\" CHAIN_ID=$(CHAIN_ID)
159-
DEFINES += BUILD_YEAR=\"$(shell date +%Y)\"
160159

161160
# Enabled Features #
162161
include makefile_conf/features.mk

client/src/ledger_app_clients/ethereum/settings.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@
55

66

77
class SettingID(Enum):
8+
BLIND_SIGNING = auto()
89
VERBOSE_ENS = auto()
9-
VERBOSE_EIP712 = auto()
1010
NONCE = auto()
11+
VERBOSE_EIP712 = auto()
1112
DEBUG_DATA = auto()
1213

1314

1415
def get_device_settings(firmware: Firmware) -> list[SettingID]:
1516
if firmware == Firmware.NANOS:
1617
return [
18+
SettingID.BLIND_SIGNING,
1719
SettingID.NONCE,
1820
SettingID.DEBUG_DATA,
1921
]
2022
return [
23+
SettingID.BLIND_SIGNING,
2124
SettingID.VERBOSE_ENS,
22-
SettingID.VERBOSE_EIP712,
2325
SettingID.NONCE,
26+
SettingID.VERBOSE_EIP712,
2427
SettingID.DEBUG_DATA,
2528
]
2629

src/common_ui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include <stdint.h>
66

77
void ui_idle(void);
8-
void ui_warning_contract_data(void);
8+
void ui_warning_blind_signing(void);
9+
void ui_error_blind_signing(void);
910
void ui_display_public_eth2(void);
1011
void ui_display_privacy_public_key(void);
1112
void ui_display_privacy_shared_secret(void);

src/handle_swap_sign_transaction.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ void __attribute__((noreturn)) handle_swap_sign_transaction(const chain_config_t
9595

9696
if (N_storage.initialized != 0x01) {
9797
internalStorage_t storage;
98-
storage.contractDetails = 0x00;
99-
storage.initialized = 0x01;
100-
storage.displayNonce = 0x00;
101-
storage.contractDetails = 0x00;
98+
explicit_bzero(&storage, sizeof(storage));
99+
storage.initialized = true;
102100
nvm_write((void*) &N_storage, (void*) &storage, sizeof(internalStorage_t));
103101
}
104102

src/main.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,7 @@ __attribute__((noreturn)) void coin_main(libargs_t *args) {
548548

549549
if (!N_storage.initialized) {
550550
internalStorage_t storage;
551-
storage.contractDetails = false;
552-
storage.displayNonce = false;
553-
#ifdef HAVE_EIP712_FULL_SUPPORT
554-
storage.verbose_eip712 = false;
555-
#endif
556-
#ifdef HAVE_DOMAIN_NAME
557-
storage.verbose_domain_name = false;
558-
#endif
551+
explicit_bzero(&storage, sizeof(storage));
559552
storage.initialized = true;
560553
nvm_write((void *) &N_storage, (void *) &storage, sizeof(internalStorage_t));
561554
}

src/shared_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef struct bip32_path_t {
3030
} bip32_path_t;
3131

3232
typedef struct internalStorage_t {
33+
bool dataAllowed;
3334
bool contractDetails;
3435
bool displayNonce;
3536
#ifdef HAVE_EIP712_FULL_SUPPORT

src/ui_callbacks.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ unsigned int io_seproxyhal_touch_eth2_address_ok(const bagl_element_t *e);
2121
unsigned int io_seproxyhal_touch_privacy_ok(const bagl_element_t *e);
2222
unsigned int io_seproxyhal_touch_privacy_cancel(const bagl_element_t *e);
2323

24-
void ui_warning_contract_data(void);
25-
2624
void io_seproxyhal_send_status(uint32_t sw);

src_bagl/common_ui.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ void ui_idle(void) {
1212
ux_flow_init(0, ux_idle_flow, NULL);
1313
}
1414

15-
void ui_warning_contract_data(void) {
16-
ux_flow_init(0, ux_blind_signing_flow, NULL);
15+
void ui_error_blind_signing(void) {
16+
ux_flow_init(0, ux_error_blind_signing_flow, NULL);
17+
}
18+
19+
void ui_warning_blind_signing(void) {
20+
ux_flow_init(0, ux_warning_blind_signing_flow, NULL);
1721
}
1822

1923
void ui_display_public_eth2(void) {

src_bagl/ui_flow.c

Lines changed: 79 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@
1010

1111
// Reuse the strings.common.fullAmount buffer for settings displaying.
1212
// No risk of collision as this buffer is unused in the settings menu
13-
#define SETTING_VERBOSE_DOMAIN_NAME_STATE (strings.common.fullAmount + (BUF_INCREMENT * 0))
14-
#define SETTING_VERBOSE_EIP712_STATE (strings.common.fullAmount + (BUF_INCREMENT * 1))
13+
#define SETTING_BLIND_SIGNING_STATE (strings.common.fullAmount + (BUF_INCREMENT * 0))
14+
#define SETTING_VERBOSE_DOMAIN_NAME_STATE (strings.common.fullAmount + (BUF_INCREMENT * 1))
1515
#define SETTING_DISPLAY_NONCE_STATE (strings.common.fullAmount + (BUF_INCREMENT * 2))
16-
#define SETTING_DISPLAY_DATA_STATE (strings.common.fullAmount + (BUF_INCREMENT * 3))
16+
#define SETTING_VERBOSE_EIP712_STATE (strings.common.fullAmount + (BUF_INCREMENT * 3))
17+
#define SETTING_DISPLAY_DATA_STATE (strings.common.fullAmount + (BUF_INCREMENT * 4))
1718

1819
#define BOOL_TO_STATE_STR(b) (b ? ENABLED_STR : DISABLED_STR)
1920

2021
static void display_settings(const ux_flow_step_t* const start_step);
22+
static void switch_settings_blind_signing(void);
23+
#ifdef HAVE_DOMAIN_NAME
24+
static void switch_settings_verbose_domain_name(void);
25+
#endif // HAVE_DOMAIN_NAME
2126
static void switch_settings_display_data(void);
2227
static void switch_settings_display_nonce(void);
2328
#ifdef HAVE_EIP712_FULL_SUPPORT
2429
static void switch_settings_verbose_eip712(void);
2530
#endif // HAVE_EIP712_FULL_SUPPORT
26-
#ifdef HAVE_DOMAIN_NAME
27-
static void switch_settings_verbose_domain_name(void);
28-
#endif // HAVE_DOMAIN_NAME
2931

3032
//////////////////////////////////////////////////////////////////////
3133
// clang-format off
@@ -70,6 +72,26 @@ UX_FLOW(ux_idle_flow,
7072
FLOW_LOOP);
7173

7274
// clang-format off
75+
UX_STEP_CB(
76+
ux_settings_flow_blind_signing_step,
77+
#ifdef TARGET_NANOS
78+
bnnn_paging,
79+
#else
80+
bnnn,
81+
#endif
82+
switch_settings_blind_signing(),
83+
{
84+
#ifdef TARGET_NANOS
85+
.title = "Blind signing",
86+
.text =
87+
#else
88+
"Blind signing",
89+
"Enables transaction",
90+
"blind signing",
91+
#endif
92+
SETTING_BLIND_SIGNING_STATE
93+
});
94+
7395
#ifdef HAVE_DOMAIN_NAME
7496
UX_STEP_CB(
7597
ux_settings_flow_verbose_domain_name_step,
@@ -83,19 +105,6 @@ UX_STEP_CB(
83105
});
84106
#endif // HAVE_DOMAIN_NAME
85107

86-
#ifdef HAVE_EIP712_FULL_SUPPORT
87-
UX_STEP_CB(
88-
ux_settings_flow_verbose_eip712_step,
89-
bnnn,
90-
switch_settings_verbose_eip712(),
91-
{
92-
"Raw messages",
93-
"Displays raw content",
94-
"from EIP712 messages",
95-
SETTING_VERBOSE_EIP712_STATE
96-
});
97-
#endif // HAVE_EIP712_FULL_SUPPORT
98-
99108
UX_STEP_CB(
100109
ux_settings_flow_display_nonce_step,
101110
#ifdef TARGET_NANOS
@@ -116,6 +125,19 @@ UX_STEP_CB(
116125
SETTING_DISPLAY_NONCE_STATE
117126
});
118127

128+
#ifdef HAVE_EIP712_FULL_SUPPORT
129+
UX_STEP_CB(
130+
ux_settings_flow_verbose_eip712_step,
131+
bnnn,
132+
switch_settings_verbose_eip712(),
133+
{
134+
"Raw messages",
135+
"Displays raw content",
136+
"from EIP712 messages",
137+
SETTING_VERBOSE_EIP712_STATE
138+
});
139+
#endif // HAVE_EIP712_FULL_SUPPORT
140+
119141
UX_STEP_CB(
120142
ux_settings_flow_display_data_step,
121143
#ifdef TARGET_NANOS
@@ -147,17 +169,19 @@ UX_STEP_CB(
147169
// clang-format on
148170

149171
UX_FLOW(ux_settings_flow,
172+
&ux_settings_flow_blind_signing_step,
150173
#ifdef HAVE_DOMAIN_NAME
151174
&ux_settings_flow_verbose_domain_name_step,
152175
#endif // HAVE_DOMAIN_NAME
176+
&ux_settings_flow_display_nonce_step,
153177
#ifdef HAVE_EIP712_FULL_SUPPORT
154178
&ux_settings_flow_verbose_eip712_step,
155179
#endif // HAVE_EIP712_FULL_SUPPORT
156-
&ux_settings_flow_display_nonce_step,
157180
&ux_settings_flow_display_data_step,
158181
&ux_settings_flow_back_step);
159182

160183
static void display_settings(const ux_flow_step_t* const start_step) {
184+
strlcpy(SETTING_BLIND_SIGNING_STATE, BOOL_TO_STATE_STR(N_storage.dataAllowed), BUF_INCREMENT);
161185
strlcpy(SETTING_DISPLAY_DATA_STATE,
162186
BOOL_TO_STATE_STR(N_storage.contractDetails),
163187
BUF_INCREMENT);
@@ -182,6 +206,10 @@ static void toggle_setting(volatile bool* setting, const ux_flow_step_t* ui_step
182206
display_settings(ui_step);
183207
}
184208

209+
static void switch_settings_blind_signing(void) {
210+
toggle_setting(&N_storage.dataAllowed, &ux_settings_flow_blind_signing_step);
211+
}
212+
185213
static void switch_settings_display_data(void) {
186214
toggle_setting(&N_storage.contractDetails, &ux_settings_flow_display_data_step);
187215
}
@@ -204,76 +232,46 @@ static void switch_settings_verbose_domain_name(void) {
204232

205233
//////////////////////////////////////////////////////////////////////
206234
// clang-format off
207-
UX_STEP_NOCB(
208-
ux_blind_signing_warning_step,
209-
pbb,
210-
{
211-
&C_icon_warning,
212235
#ifdef TARGET_NANOS
213-
"Transaction",
214-
"not trusted",
215-
#else
216-
"This transaction",
217-
"cannot be trusted",
218-
#endif
219-
});
220-
#ifndef TARGET_NANOS
221-
UX_STEP_NOCB(
222-
ux_blind_signing_text1_step,
223-
nnnn,
236+
UX_STEP_CB(
237+
ux_error_blind_signing_step,
238+
bnnn_paging,
239+
ui_idle(),
224240
{
225-
"Your Ledger cannot",
226-
"decode this",
227-
"transaction. If you",
228-
"sign it, you could",
241+
"Error",
242+
"Blind signing must be enabled in Settings",
229243
});
230-
UX_STEP_NOCB(
231-
ux_blind_signing_text2_step,
232-
nnnn,
244+
#else
245+
UX_STEP_CB(
246+
ux_error_blind_signing_step,
247+
pnn,
248+
ui_idle(),
233249
{
234-
"be authorizing",
235-
"malicious actions",
236-
"that can drain your",
237-
"wallet.",
250+
&C_icon_crossmark,
251+
"Blind signing must be",
252+
"enabled in Settings",
238253
});
239254
#endif
255+
240256
UX_STEP_NOCB(
241-
ux_blind_signing_link_step,
242-
nn,
243-
{
244-
"Learn more:",
245-
"ledger.com/e8",
246-
});
247-
UX_STEP_CB(
248-
ux_blind_signing_accept_step,
257+
ux_warning_blind_signing_warn_step,
249258
pbb,
250-
start_signature_flow(),
251259
{
252-
&C_icon_validate_14,
253-
#ifdef TARGET_NANOS
254-
"Accept risk",
255-
"and review",
256-
#else
257-
"Accept risk and",
258-
"review transaction",
259-
#endif
260-
});
261-
UX_STEP_CB(
262-
ux_blind_signing_reject_step,
263-
pb,
264-
report_finalize_error(),
265-
{
266-
&C_icon_crossmark,
267-
"Reject",
260+
&C_icon_warning,
261+
"Blind",
262+
"signing",
268263
});
264+
UX_STEP_INIT(
265+
ux_warning_blind_signing_jump_step,
266+
NULL,
267+
NULL,
268+
{
269+
start_signature_flow();
270+
}
271+
);
269272
// clang-format on
270273

271-
UX_FLOW(ux_blind_signing_flow,
272-
&ux_blind_signing_warning_step,
273-
#ifndef TARGET_NANOS
274-
&ux_blind_signing_text1_step,
275-
&ux_blind_signing_text2_step,
276-
#endif
277-
&ux_blind_signing_link_step,
278-
&ux_blind_signing_accept_step,
279-
&ux_blind_signing_reject_step);
274+
UX_FLOW(ux_error_blind_signing_flow, &ux_error_blind_signing_step);
275+
UX_FLOW(ux_warning_blind_signing_flow,
276+
&ux_warning_blind_signing_warn_step,
277+
&ux_warning_blind_signing_jump_step);

0 commit comments

Comments
 (0)