Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebMIDI usage is missed due to obfuscated function call #53

Closed
bgrins opened this issue Oct 18, 2022 · 4 comments
Closed

WebMIDI usage is missed due to obfuscated function call #53

bgrins opened this issue Oct 18, 2022 · 4 comments

Comments

@bgrins
Copy link
Member

bgrins commented Oct 18, 2022

I wanted to share something I came across digging into data from https://github.com/HTTPArchive/almanac.httparchive.org/blob/main/sql/2022/capabilities/fugu.sql

https://shopee.co.th/shopeeth loads a script https://deo.shopeemobile.com/shopee/web-sdk/js/live/613832263d29374ef4cd566434d8f268cb15367d.js with the following:

var fD=fC[yO(0x3c4,'QQOo')+'or'][yN(0x95b,'qQOo')+'MIDIAcc'+yN(0x318,'QqQQ')]()

Which is turning into a call to navigator.requestMIDIAccess() at runtime. Obviously this is missed from the check of /navigator\.requestMIDIAccess\s*\(/g, at

'WebMIDI': {
regEx: /navigator\.requestMIDIAccess\s*\(/g,
where: 'JavaScript',
supported: (async () => 'requestMIDIAccess' in navigator)(),
featureDetection: `(async () => 'requestMIDIAccess' in navigator)()`,
documentation:
'https://developer.mozilla.org/en-US/docs/Web/API/Web_MIDI_API',
blinkFeatureID: 2029,

I think this might just be a fundamentally unfixable problem, but I thought I'd raise it to see if anyone had ideas on how to better detect sites using these types of APIs at runtime in a way that would result in fewer false negatives in the custom metric.

@pmeenan
Copy link
Member

pmeenan commented Oct 18, 2022 via email

@bgrins
Copy link
Member Author

bgrins commented Oct 19, 2022 via email

@tomayac
Copy link
Member

tomayac commented Oct 19, 2022

Hi @bgrins, @tomayac here, author of the detector script from your initial comment. Obfuscated code is indeed a problem, and there's no solution unfortunately. What @pmeenan suggests might work for your use case, this is the UseCounter for opening a MIDI port, which correlates well with actual usage: https://chromestatus.com/metrics/feature/timeline/popularity/2029.

@tomayac tomayac closed this as completed Oct 19, 2022
@rviscomi
Copy link
Member

We've started implementing a solution that adds observers to a set of global objects. So regardless of any obfuscation in the source code, we'd be able to detect that a given function was called or property accessed. We could even log the arguments and call stack.

We had to disable it due to edge cases that caused pages not to load properly, but I'd love to revisit that idea. It'd help with this use case of tracking Fugu API usage. I've filed #54 to track this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants