Skip to content

Commit 0aadb6c

Browse files
committed
Update Frida script to handle TLS null callbacks
1 parent 4bf5da9 commit 0aadb6c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

overrides/frida/native-tls-hook.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function patchTargetLib(targetLib) {
9090
);
9191

9292
const SSL_VERIFY_OK = 0x0;
93+
const SSL_VERIFY_INVALID = 0x1;
9394

9495
// We cache the verification callbacks we create. In general (in testing, 100% of the time) the
9596
// 'real' callback is always the exact same address, so this is much more efficient than creating
@@ -98,13 +99,15 @@ function patchTargetLib(targetLib) {
9899

99100
const buildVerificationCallback = (realCallbackAddr) => {
100101
if (!verificationCallbackCache[realCallbackAddr]) {
101-
const realCallback = new NativeFunction(realCallbackAddr, 'int', ['pointer','pointer']);
102+
const realCallback = realCallbackAddr
103+
? new NativeFunction(realCallbackAddr, 'int', ['pointer','pointer'])
104+
: () => SSL_VERIFY_INVALID; // Callback can be null - treat as invalid (=our validation only)
102105

103106
const hookedCallback = new NativeCallback(function (ssl, out_alert) {
104107
let realResult = false;
105108

106109
if (targetLib !== 'libboringssl.dylib') {
107-
// Cronet assumes its callback is always calls, and crashes if not. iOS's BoringSSL
110+
// Cronet assumes its callback is always called, and crashes if not. iOS's BoringSSL
108111
// meanwhile seems to use some negative checks in its callback, and rejects the
109112
// connection independently of the return value here if it's called with a bad cert.
110113
// End result: we *only sometimes* proactively call the callback.

0 commit comments

Comments
 (0)