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

Chrome impersonation fails because of insufficient ALPS implementation #54

Open
vladfrangu opened this issue Feb 17, 2025 · 1 comment

Comments

@vladfrangu
Copy link
Member

As talked on Slack, reporting here for tracking purposes

Test file:

import { Browser, Impit } from 'impit';

const impit = new Impit({ browser: Browser.Chrome });

const buff = await impit.fetch('https://www.google.com/');

console.log(buff.status);
console.log(buff.headers);
console.log(await buff.text());

Error:

❯ node --experimental-strip-types impit.ts                                      
node:internal/modules/run_main:122
    triggerUncaughtException(
    ^

[Error: RequestError(
    reqwest::Error {
        kind: Request,
        url: "https://www.google.com/",
        source: hyper_util::client::legacy::Error(
            SendRequest,
            hyper::Error(
                Io,
                Custom {
                    kind: InvalidData,
                    error: "received fatal alert: UnexpectedMessage",
                },
            ),
        ),
    },
)] {
  code: 'GenericFailure'
}

Node.js v22.13.0
@barjin
Copy link
Contributor

barjin commented Feb 21, 2025

Upon deeper inspection, this seems more like a Client Hints via ALPS (Application layer protocol settings) issue.

See that the Unexpected Message (0x02 0x0a) TLS Alert comes right after the Client sends the HTTP/2 headers.

Image

In the ALPN/ALPS extension message, the server picks HTTP/2 and sends an ALPS message containing what seems like HTTP header names:

Image

Unfortunately, making impit send those headers doesn't solve this issue.

Removing the ALPS extension from the ClientHello sent by Impit does make the requests work.
For now, we could mitigate this issue like this, but this makes Impit more detectable (as it directly modifies - among others - its JA4 fingerprint).

@barjin barjin changed the title Cannot fetch certain websites due to post-quantum ciphersuite Chrome impersonation fails because of insufficient ALPS implementation Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants