CWE-939: Improper Authorization in Handler for Custom URL Scheme
The product uses a handler for a custom URL scheme, but it does not properly restrict which actors can invoke the handler using the scheme.
How it's found
Improper Authorization in Handler for Custom URL Scheme is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
Mobile platforms and other architectures allow the use of custom URL schemes to facilitate communication between applications. In the case of iOS, this is the only method to do inter-application communication. The implementation is at the developer's discretion which may open security flaws in the application. An example could be potentially dangerous functionality such as modifying files through a custom URL scheme.
Vulnerable vs. safe
return NO;
//this function will write contents to a specified fileNSDictionary *dict = [self parseQueryStringExampleFunction:[url query]];FileObject *objectFile = [self writeToFile:[dict objectForKey: @"file"] withText:[dict objectForKey: @"text"]];
if (!url) {}NSString *action = [url host];if([action isEqualToString: @"replaceFileText"]) {}return YES;- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {}NSString *stringURL = @"appscheme://replaceFileText?file=incomingMessage.txt&text=hello";NSURL *url = [NSURL URLWithString:stringURL];[[UIApplication sharedApplication] openURL:url];Consequences
- Gain Privileges or Assume Identity, Varies by Context, Bypass Protection Mechanism: An attacker can access any functionality that is inadvertently accessible to the source.
Mitigations
- Architecture and Design: Utilize a user prompt pop-up to authorize potentially harmful actions such as those modifying data or dealing with sensitive information. When designing functionality of actions in the URL scheme, consider whether the action should be accessible to all mobile applications, or if an allowlist of applications to interface with is appropriate.
Where this fits in a TurboPentest engagement
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
Frequently asked questions
What is CWE-939?
The product uses a handler for a custom URL scheme, but it does not properly restrict which actors can invoke the handler using the scheme.
How do you find Improper Authorization in Handler for Custom URL Scheme?
Improper Authorization in Handler for Custom URL Scheme is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
What is the impact of CWE-939?
Gain Privileges or Assume Identity, Varies by Context, Bypass Protection Mechanism: An attacker can access any functionality that is inadvertently accessible to the source.
Does TurboPentest test for Improper Authorization in Handler for Custom URL Scheme?
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
Related CWEs
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a $99 pentest