Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/webrtc-session-signal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@prosopo/types": patch
"@prosopo/types-database": patch
"@prosopo/provider": patch
---

Extend the WebRTC session signal.
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,17 @@ export const evaluateWebRtc = async ({
}

const leakedIp = comparable[0]?.address;
let leaked: WebRtcSignal["leaked"];
let network: WebRtcSignal["leaked"];
if (leakedIp) {
try {
leaked = await leakedNetwork(leakedIp, ipInfoService);
network = await leakedNetwork(leakedIp, ipInfoService);
} catch (err) {
logger.debug(() => ({ msg: "leaked address lookup failed", err }));
}
}
return {
...withSeen,
outcome: WebRtcOutcome.mismatch,
...(leaked && { leaked }),
...(leakedIp && { leaked: { ip: leakedIp, ...network } }),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,45 @@ describe("evaluateWebRtc", () => {
});
});

it("is a mismatch behind a proxy, recording the leaked network but not the address", async () => {
it("is a mismatch behind a proxy, recording the leaked address and its network", async () => {
const signal = await evaluate(
report([mdnsHost, srflx(REAL_IP, 49637)]),
PROXY_IP,
);
expect(signal?.outcome).toBe(WebRtcOutcome.mismatch);
expect(signal?.leaked).toEqual({
ip: REAL_IP,
asnNumber: 5089,
countryCode: "GB",
isProxy: false,
isVPN: false,
isDatacenter: false,
});
expect(JSON.stringify(signal)).not.toContain(REAL_IP);
});

it("records the leaked address even when its network cannot be looked up", async () => {
const unavailable: IIpInfoService = {
...ipInfoService,
isAvailable: (): boolean => false,
};
const signal = await evaluateWebRtc({
report: report([mdnsHost, srflx(REAL_IP, 49637)]),
requestIp: PROXY_IP,
socketPath,
ipInfoService: unavailable,
logger,
});
expect(signal?.outcome).toBe(WebRtcOutcome.mismatch);
expect(signal?.leaked).toEqual({ ip: REAL_IP });
});

it("does not record an address on a match", async () => {
const signal = await evaluate(
report([mdnsHost, srflx(REAL_IP, 49637)]),
REAL_IP,
);
expect(signal?.outcome).toBe(WebRtcOutcome.match);
expect(signal?.leaked).toBeUndefined();
});

it("flags a candidate no STUN request matches", async () => {
Expand Down
1 change: 1 addition & 0 deletions packages/types-database/src/types/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ const WebRtcSignalRecordSchema = new Schema<WebRtcSignal>(
leaked: {
type: new Schema(
{
ip: { type: String, required: false },
asnNumber: { type: Number, required: false },
countryCode: { type: String, required: false },
isProxy: { type: Boolean, required: false },
Expand Down
5 changes: 3 additions & 2 deletions packages/types/src/provider/webrtc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const WebRtcProbeReportSchema = z.object({

export type WebRtcProbeReport = z.infer<typeof WebRtcProbeReportSchema>;

// Stored on the session. Holds no raw address: a mismatch records the leaked
// address's network, not the address.
// Stored on the session. A mismatch records the leaked address and its
// network, so a site can block the machine behind the proxy, not only the exit.
export const WebRtcSignalSchema = z.object({
outcome: z.nativeEnum(WebRtcOutcome),
clientStatus: z.nativeEnum(WebRtcClientStatus),
Expand All @@ -68,6 +68,7 @@ export const WebRtcSignalSchema = z.object({
requestIpSeen: z.boolean().optional(),
leaked: z
.object({
ip: z.string().max(45).optional(),
asnNumber: z.number().int().optional(),
countryCode: z.string().max(8).optional(),
isProxy: z.boolean().optional(),
Expand Down
Loading