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
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
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?
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Related CWEs
Written and reviewed by
Michel Chamberland - Founder & CEO, IntegSec
CISSP, OSCP, OSCE, CEH, GIAC, CCSK · 20+ years in offensive security
Michel has spent 20+ years on offensive security teams including IBM X-Force Red and Trustwave SpiderLabs, leading penetration tests, red team engagements, and breach response for Fortune 500 customers. He is the founder of IntegSec and the architect of TurboPentest.
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 pentest