aeharding / aeharding/voyager

Potential exposure of cookies to JavaScript through Capacitor cookie shim on Android

Offen
#2,264 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
1.8k
Forks
174
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

## Product version
Analyzed Android app version: `848`

## Description
We analysed this app with our static analyser (not based on LLM) for java-javascript hybid apps. It detected a cookie shim pattern in the Android WebView layer that overrides `document.cookie` and, on Android, returns the original cookie getter.

Relevant code:

```js
Object.defineProperty(document, 'cookie', {
get: function () {
var _a, _b, _c;
if (platform === 'ios') {
const payload = {
type: 'CapacitorCookies.get',
};
const res = prompt(JSON.stringify(payload));
return res;
}
else if (typeof win.CapacitorCookiesAndroidInterface !== 'undefined') {
// return original document.cookie since Android does not support filtering of `httpOnly` cookies
return (_c = (_b = (_a = win.CapacitorCookiesDescriptor) === null || _a === void 0 ? void 0 : _a.get) === null || _b === void 0 ? void 0 : _b.call(document)) !== null && _c !== void 0 ? _c : '';
}
},
set: function (val) {
const cookiePairs = val.split(';');
const domainSection = val.toLowerCase().split('domain=')[1];
const domain = cookiePairs.length > 1 && domainSection != null && domainSection.length > 0
? domainSection.split(';')[0].trim()
: '';
if (platform === 'ios') {
const payload = {
type: 'CapacitorCookies.set',
action: val,
domain,
};
prompt(JSON.stringify(payload));
}
else if (typeof win.CapacitorCookiesAndroidInterface !== 'undefined') {
win.CapacitorCookiesAndroidInterface.setCookie(domain, val);
}
},
});

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.