Skip to content

openssl: map Android 14 keylog labels by endpoint role - #1106

Merged
cfc4n merged 3 commits into
gojue:masterfrom
yunwei37:bugfix/boringssl-android14-keylog-role
Dec 2, 2026
Merged

cfc4n merged 3 commits into
gojue:masterfrom
yunwei37:bugfix/boringssl-android14-keylog-role

Conversation

@yunwei37

@yunwei37 yunwei37 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Android 14 BoringSSL header omits BSSL__SSL_ST_SERVER. The shared SSL_do_handshake fallback therefore takes its historical server mapping for both endpoint roles. On a client, the emitted CLIENT_TRAFFIC_SECRET_0 carries the server application secret and SERVER_TRAFFIC_SECRET_0 the client application secret. The exporter is unaffected.

Change

Supply the server-role bit offset (0xa4) in the Android 14 header so the existing role-aware mapping is used. No new extraction path.

The Android 14 BoringSSL x86-64 build packaged by Debian (android-libboringssl 14.0.0+r45-2, libssl.so.0 SHA256 b86b018e…) implements SSL_is_server as movzbl 0xa4(%rdi),%eax; and $0x1,%eax, bit zero at that offset. The Android 17 header already uses the same role field.

Validation

  • A regression in the existing offset tests: the Android 14 case fails before the define and passes after it, with Android 17 as a control. go test -race -count=1 ./test/offsets/ passes.
  • Kernel eBPF as root, CO-RE builds (make build_core) of master 9c00018 and this branch, tls -m keylog --ssl_version boringssl_a_14 against that library, which carries no .gnu_debugdata, so the fallback is used. The TLS 1.3 client logs its reference keys with SSL_CTX_set_keylog_callback:
    • master writes 3 records: the exporter matches, and the two application secrets appear under each other's label;
    • this branch writes the same 3 records, all byte-equal under the correct labels.
  • Ubuntu 24.04 on WSL2, Linux 6.18.58.1, x86-64, clang 18.1.3. The non-CO-RE build and Android devices were not tested.

Remaining limitation

The SSL_do_handshake fallback still emits no handshake-secret records: the client's own log has five records, this path three. That is a property of the fallback hook; #1107 lets libraries with symbols use the label-based hook, which reports all five.

The fallback needs the server-role field to distinguish client and server
application secrets. Android 14 omitted that confirmed field offset.
Copilot AI balanced review requested due to automatic review settings December 1, 2026 05:06
@dosubot

dosubot Bot commented Dec 1, 2026

Copy link
Copy Markdown

📄 Knowledge review

✏️ Suggested updates

1 page suggestion needs review.

Page Library Status
CHANGELOG /ecapture/blob/master/CHANGELOG.md ecapture ⬆️ Pushed to this PR

Leave Feedback Ask Dosu about ecapture Add Dosu to your team

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Maintainer review is needed because the ABI offset controlling TLS secret labels was validated only on Linux x86-64, leaving Android/arm64 layout compatibility and the required non-CO-RE build unverified.

No open issues 🎉

What changed in this PR

Fixes swapped client/server application-secret labels in the Android 14 BoringSSL SSL_do_handshake fallback by enabling the existing endpoint-role mapping.

Changes:

  • Defines the Android 14 server-role bit offset as 0xa4, without introducing a new extraction path.
  • Adds an offset regression test for Android 14, with Android 17 as a control.
File Description
test/​offsets/​boringssl_offsets_test.go Checks that Android 14 and 17 define the expected endpoint-role offset.
kern/​boringssl_a_14_kern.c Adds the role offset used to select the correct application-secret labels.

Review effort: Balanced

@yunwei37

yunwei37 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up validation for b2b06ac1:

  • Debian's AArch64 android-libboringssl 14.0.0+r45-2 confirms the same endpoint-role field. SSL_is_server disassembles to ldrb w8, [x0, #0xa4] followed by and w0, w8, #0x1. Package SHA256 6dd20f2d7ad3cdff7c80d8076feea6258c8e9f0a0a23ad85d447eeb3e7f11c36 matches the Debian checksum; the extracted ELF reports AArch64.
  • The x86-64 build and arm64 build both completed CO-RE and non-CO-RE compilation, including boringssl_a_14_kern.c. Logs identify the tested merge as 6175884, merging this exact head into 9c00018. Android cross-builds also passed.
  • Android API 34 E2E built the non-CO-RE Android x86-64 binary and selected boringssl_a_14 from the emulator's Conscrypt library. Text, keylog and pcapng-with-DSB passed (3/3); the keylog case decrypted the TLS 1.2 and TLS 1.3 request marker.

This supplies the missing build evidence and an Android x86-64 runtime check. The AArch64 disassembly checks this Debian library's role offset; Android arm64 runtime validation remains untested. These CI runs use kernel eBPF and do not extend the separate rootless bpftime acceptance claim.

cfc4n added 2 commits December 2, 2026 22:17
Use the offsets generated from each Android release so the TLS 1.3
handshake fallback labels application secrets by endpoint role on
Android 15 and 16. Refresh Android 14 from the same generator and
cover the two additional versions in the existing offset regression.
Keep the Android 15 offsets explicit so the only change to its original
header is the endpoint role used to label application secrets.
@cfc4n
cfc4n merged commit 204c5ba into gojue:master Dec 2, 2026
15 checks passed
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

Successfully merging this pull request may close these issues.

3 participants