This is an automated email from the ASF dual-hosted git repository.

NiklasMerz pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git


The following commit(s) were added to refs/heads/master by this push:
     new e0bd9dc  fix(ios): check callbackId with regex (#1152)
e0bd9dc is described below

commit e0bd9dc95b23893528dd2685d13a424a48ca7717
Author: Niklas Merz <[email protected]>
AuthorDate: Wed May 20 22:15:19 2026 +0200

    fix(ios): check callbackId with regex (#1152)
---
 src/ios/CDVWKInAppBrowser.m | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m
index b826c92..ddc9505 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -624,6 +624,18 @@
         NSDictionary *messageContent = (NSDictionary *) message.body;
         NSString *scriptCallbackId = messageContent[@"id"];
 
+        // Only allow callback ids generated by this plugin, e.g. 
"InAppBrowser123".
+        if (![scriptCallbackId isKindOfClass:[NSString class]]) {
+            NSLog(@"InAppBrowser callback called with missing or non-string 
callback id");
+            return;
+        }
+
+        NSRegularExpression *callbackIdRegex = [NSRegularExpression 
regularExpressionWithPattern:@"^InAppBrowser[0-9]{1,10}$" options:0 error:nil];
+        if ([callbackIdRegex firstMatchInString:scriptCallbackId options:0 
range:NSMakeRange(0, scriptCallbackId.length)] == nil) {
+            NSLog(@"InAppBrowser callback called with invalid callbackId: %@", 
scriptCallbackId);
+            return;
+        }
+
         if ([messageContent objectForKey:@"d"]) {
             NSString *scriptResult = messageContent[@"d"];
             NSError * __autoreleasing error = nil;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to