Closed Restioson closed 12 months ago
cc @luckysori, from our discussion on #1103
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Will be fixed with #843 and another ticket which will move the margin into the DLC (https://github.com/get10101/10101/issues/1277)
Alright, sounds good! Should we not keep this open until then? It just seems like it could be forgotten otherwise :sweat_smile: as it seems a little orthogonal to those two tickets (correct me if I'm wrong)
Will be closed once the referenced tickets are resolved.
Currently, we trust the invoice description to correctly identify the type of transaction as well as any associated data, such as an order id (an example of CWE-502).
https://github.com/get10101/10101/blob/65f4a2fb766885ffa9e5ec528d9b5305d7fe8c85/mobile/native/src/ln_dlc/mod.rs#L351-L356
What happens if the user creates their own invoice with the description
taker-fee-NotAnOrderId?!/.sidfj
? Or, worse, what if the user pays an invoice without looking at the description? These would both show up as trade-related payments in the history. This is bad UX at best, and a security vulnerability at worst.Imagined social engineering attack:
This is slightly contrived, as we do not expect any of our users to fall for this especially since the beta users should have some idea of how the app works. Note that this scam can still progress to the point of paying 1000 sats in the above example even if this is fixed.
Furthermore, in general, parsing untrusted data is not recommended to be done lightly (see OWASP - Deserialization of untrusted data). Most parsers are not designed to handle untrusted data. What we are doing is probably fine for now (just stripping the prefix), but this could change and introduce a vulnerability.
There should be another way to figure out the type of payment from a trusted source. Perhaps this could be stored in the database? Presumably order info is already stored there.
If we can authenticate that the invoice was created by the user themselves, then we can also trust the description. This might be a bit brittle, though, since it might seem as though we can trust the description in all cases (when in reality we can only trust it if we know the user generated the payment). Maybe, in that case, it is best to also store the associated data in the database.