Summary
JSON.parseExn throws an exception on invalid JSON input. Several call sites use it on untrusted data (sessionStorage, DOM events, API error messages) without adequate error handling, which can cause application crashes or expose unexpected behavior.
Affected Locations
| # |
File |
Line |
Input Source |
Error Handling |
Risk |
| 1 |
src/context/FilterContext.res |
177 |
sessionStorage |
None |
HIGH |
| 2 |
src/components/HandlingEvents.res |
12 |
postMessage DOM event |
try/catch present |
MEDIUM |
| 3 |
src/screens/Developer/PaymentSettingsRevamped/AcquirerConfigSettingsRevamp/AcquirerConfigSettingsRevamp.res |
62 |
API error message |
outer try/catch only |
MEDIUM |
| 4 |
src/screens/Developer/PaymentSettings/AcquirerConfigSettings/AcquirerConfigSettings.res |
61 |
API error message |
outer try/catch only |
MEDIUM |
| 5 |
src/screens/PaymentLinkThemeConfigurator/PaymentLinkThemeConfiguratorTool.res |
61 |
WASM return value |
outer try/catch only |
MEDIUM |
src/utils/LogicUtils.res line 36 (safeParseOpt) is a safe wrapper and is not an issue.
Highest-Risk Case — FilterContext.res Line 177
switch sessionStorage.getItem(`${index}-list`)->Nullable.toOption {
| Some(value) =>
switch value->JSON.parseExn->JSON.Decode.array { // <-- no try/catch
| Some(arr) => ...
| None => ()
}
| None => ()
}
sessionStorage can be written by any same-origin JavaScript. If the stored value is malformed JSON, JSON.parseExn throws an unhandled exception that crashes the filter context, breaking the dashboard UI.
Impact
- FilterContext crash: corrupted or attacker-manipulated sessionStorage can force an unhandled exception, making filters non-functional
- Cascading failures: other call sites with only outer-scope try/catch may silently swallow errors and leave the UI in an inconsistent state
Severity: MEDIUM–HIGH
Recommended Fix
- FilterContext.res line 177 — wrap with an immediate try/catch or use
LogicUtils.safeParseOpt instead of JSON.parseExn
- All other sites — replace
JSON.parseExn on untrusted sources with LogicUtils.safeParseOpt and handle the None case explicitly
- Establish a lint rule or code review checklist item:
JSON.parseExn must never be called without a surrounding try/catch or a safe-parse wrapper when the source is external (API, storage, events)
References
Summary
JSON.parseExnthrows an exception on invalid JSON input. Several call sites use it on untrusted data (sessionStorage, DOM events, API error messages) without adequate error handling, which can cause application crashes or expose unexpected behavior.Affected Locations
src/context/FilterContext.ressessionStoragesrc/components/HandlingEvents.respostMessageDOM eventsrc/screens/Developer/PaymentSettingsRevamped/AcquirerConfigSettingsRevamp/AcquirerConfigSettingsRevamp.ressrc/screens/Developer/PaymentSettings/AcquirerConfigSettings/AcquirerConfigSettings.ressrc/screens/PaymentLinkThemeConfigurator/PaymentLinkThemeConfiguratorTool.resHighest-Risk Case — FilterContext.res Line 177
sessionStoragecan be written by any same-origin JavaScript. If the stored value is malformed JSON,JSON.parseExnthrows an unhandled exception that crashes the filter context, breaking the dashboard UI.Impact
Severity: MEDIUM–HIGH
Recommended Fix
LogicUtils.safeParseOptinstead ofJSON.parseExnJSON.parseExnon untrusted sources withLogicUtils.safeParseOptand handle theNonecase explicitlyJSON.parseExnmust never be called without a surrounding try/catch or a safe-parse wrapper when the source is external (API, storage, events)References