approval: disclose NIP-04 requests with a legacy banner (I2)

This commit is contained in:
raucao committed 2026-11-30 03:11:19 +04:00
1 parent 904743334d
commit ea670ca8e2
2 files changed
+46

No files matched your search

+4
View File
@@ -102,6 +102,10 @@ data/ desktop, metainfo, gschema (all `.in` templates), icons, re
- **Decryption always asks.** It is a content oracle, so `Decrypt` never stores a
permission and the dialog offers only Deny / Allow once. Silently decrypting
is the exact flaw this project exists to replace; do not "optimise" it away.
- **NIP-04 is flagged (I2).** A `nip04_encrypt`/`nip04_decrypt` request adds an
above-the-fold banner saying NIP-04 is the older, unauthenticated scheme and
NIP-44 is recommended (`request_warnings`, comparing the `nim_name` form
`"nip04"`).
- **Rate limit.** `signer::policy::RateLimiter` caps silent answers per app:
`auto-approve-limit` requests per minute (GSettings, default **30**). Past the
cap the request is asked again, so a runaway or compromised client turns back
+42
View File
@@ -889,6 +889,16 @@ fn request_warnings(request: &Request) -> Vec<String> {
}
_ => {}
}
// NIP-04 is the unauthenticated legacy scheme; disclose it (I2).
if let Request::Encrypt { method, .. } | Request::Decrypt { method, .. } = request
&& *method == "nip04"
{
warnings.push(
"This application asked for NIP-04, an older scheme without \
authentication. NIP-44 is recommended."
.to_string(),
);
}
warnings
}
@@ -1080,4 +1090,36 @@ mod tests {
assert_eq!(warnings.len(), 1, "{warnings:?}");
assert!(warnings[0].contains("32 KiB"));
}
/// A NIP-04 request is disclosed as the legacy scheme (I2). The `method` is
/// the `nim_name` form ("nip04"/"nip44"), not the full method name.
#[test]
fn a_nip04_request_is_flagged() {
let encrypt = Request::Encrypt {
method: "nip04",
peer: "npub1".to_string(),
message: "hi".to_string(),
message_chars: 2,
};
let warnings = request_warnings(&encrypt);
assert_eq!(warnings.len(), 1, "{warnings:?}");
assert!(warnings[0].contains("NIP-04"));
let decrypt = Request::Decrypt {
method: "nip04",
peer: "npub1".to_string(),
preview: "cipher".to_string(),
};
let warnings = request_warnings(&decrypt);
assert_eq!(warnings.len(), 1, "{warnings:?}");
assert!(warnings[0].contains("NIP-04"));
let nip44 = Request::Encrypt {
method: "nip44",
peer: "npub1".to_string(),
message: "hi".to_string(),
message_chars: 2,
};
assert!(request_warnings(&nip44).is_empty());
}
}