link_parameter_opened_unchecked
Reports an address made from an incoming link that the app opens in a WebView or a browser without checking it. Open it only after checking its scheme and host against the hosts you expect.
- Tier
- advisory
- Scope
- Flutter
- Lowest preset
- recommended
- Fix
- none
- Security class
- CWE-601, CWE-939 · mobile risk M4 (insufficient input/output validation) · severity 6.1
What it reports
Section titled “What it reports”The address given to loadRequest of a webview_flutter WebViewController, or to url_launcher’s launchUrl, launchUrlString or launch, when the same function makes it from a link from outside the app. The violation is on the address.
A link from outside the app is:
- go_router: the
uriof aGoRouterState(and itsqueryParameters[…]) and itspathParameters[…], read in the function (state.uri,GoRouterState.of(context).uri). Never itsextra, which the app hands to a route itself (context.go(…, extra: url)): go_router’s parser gives a link that opens the app a state without one. - app_links: the parameter of a function literal given to
listenonuriLinkStreamorstringLinkStream, and the awaited value ofgetInitialLink,getInitialLinkString,getLatestLinkorgetLatestLinkString.
The flow goes through final locals, Uri.parse and Uri.tryParse, interpolation, +, !, ??, casts and toString().
It does not report:
- an open under a condition that names the link or a local made from it: of an
if(itswhentoo), a conditional, aswitch,&&or||; - an open after an
ifthat names the link and can leave:if (!isAllowed(uri)) return;; - an address that writes its own scheme and host, the link only adding to its path or query:
'https://shop.dev/items/$id',Uri.https('shop.dev', …), or a constant of a whole address before it,'$shop${state.uri.path}', ascleartext_requestreads one; - a link that only picks among fixed addresses:
pages[state.pathParameters['page']]; - a link handed to project code first, where the flow ends;
- a listener torn off:
listen(_open); - debug-only code, and the test side.
A test of null or of a type is not a check of where the link leads. Neither is canLaunchUrl, which only says whether some app can open the link.
Anyone can send a link that opens the app: in a mail, a message, a web page. If the app opens the address the link carries, in its own WebView (which looks like the app) or in the browser, the sender chooses the page: a copy of the app’s sign-in that collects passwords, a page that calls the WebView’s channels, a download.
Example
Section titled “Example”GoRoute( path: '/web', builder: (context, state) => WebViewWidget( controller: WebViewController() ..loadRequest(Uri.parse(state.uri.queryParameters['url']!)), ),);final target = Uri.parse(state.uri.queryParameters['url']!);if (target.scheme != 'https' || target.host != 'shop.dev') return const NotFound();return WebViewWidget(controller: WebViewController()..loadRequest(target));Rule parameters
Section titled “Rule parameters”Set under the assay: key of the project’s root analysis_options.yaml.
| Rule parameter | Default | Effect |
|---|---|---|
enabled |
true |
false switches the rule off for the whole project. |
exclude |
[] |
Path globs where the rule is silent. |
Security class
Section titled “Security class”In SARIF, the rule’s descriptor carries the tags security, external/cwe/cwe-601, external/cwe/cwe-939 and external/owasp-mobile-2024/m4, and the security-severity 6.1. No other report changes.
Suppressing it
Section titled “Suppressing it”Write why on the line directly above the suppression:
// The link is signed by our server, and the signature is checked by the router.// ignore: link_parameter_opened_unchecked// ignore_for_file: assay/link_parameter_opened_unchecked silences it in a whole file, and // ignore: assay/link_parameter_opened_unchecked with the prefix works too. See Suppressions.