Skip to content

openssl: resolve BoringSSL keylog symbols on Linux - #1107

Merged
cfc4n merged 2 commits into
gojue:masterfrom
yunwei37:bugfix/boringssl-linux-keylog-symbols
Dec 2, 2026
Merged

cfc4n merged 2 commits into
gojue:masterfrom
yunwei37:bugfix/boringssl-linux-keylog-symbols

Conversation

@yunwei37

@yunwei37 yunwei37 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On Linux, eCapture tries BoringSSL's label-based keylog hook only when IsAndroid is true, and the resolver reads only Android's .gnu_debugdata. An unstripped Linux BoringSSL keeps bssl::ssl_log_secret in its ordinary ELF symbol table, yet keylog and pcapng modes take the SSL_do_handshake return fallback, which emits only the application and exporter secrets.

Change

  • Resolve the hook from the ordinary ELF symbol table first, then from Android's .gnu_debugdata as before.
  • Try the hook for Linux BoringSSL in the same modes as Android. A stripped library without .gnu_debugdata keeps the existing fallback and its diagnostic.

The BPF code is unchanged.

Verification

  • A new test compiles a shared library with a hidden function under the hook's symbol name. The resolver returns that function's file offset; after objcopy --strip-all it returns an error, so configuration keeps the fallback. With master's resolver the first check fails with BoringSSL ELF has no .gnu_debugdata section. go test -race -count=1 ./internal/probe/openssl/ passes; gofmt and go vet report nothing.
  • Library: Debian's android-libboringssl 14.0.0+r45-2 amd64 (libssl.so.0, SHA256 b86b018e…) with its symbol table merged back from the matching -dbgsym package by eu-unstrip; the LOAD headers are unchanged. The resolver returns file offset 0x465e0.
  • 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. The TLS 1.3 client logs its reference keys with SSL_CTX_set_keylog_callback, five records:
    • master stays on the fallback and writes 3: the exporter matches, the two application secrets carry each other's label (fixed separately by openssl: map Android 14 keylog labels by endpoint role #1106), and both handshake secrets are missing;
    • this branch hooks ssl_log_secret and writes all 5 (both handshake secrets, both application secrets and the exporter), byte-equal under the same labels.
  • Ubuntu 24.04 on WSL2, Linux 6.18.58.1, x86-64, Go 1.26.11, clang 18.1.3.

Use ordinary ELF symbols or a matching GNU debug companion for the existing
label-based hook, while retaining Android mini debug support and fallback.
@yunwei37
yunwei37 marked this pull request as ready for review December 1, 2026 05:51
Copilot AI balanced review requested due to automatic review settings December 1, 2026 05:51
@dosubot

dosubot Bot commented Dec 1, 2026

Copy link
Copy Markdown

📄 Knowledge review

✏️ Suggested updates

1 page suggestion needs review.

Page Library Status
README /ecapture/blob/master/README.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.

🟡 Changes recommended

Debug-symbol discovery can miss valid companions after mini-debug failures or when the library path is a symlink, causing unnecessary handshake fallback and loss of handshake-secret records.

2 open issues
What changed in this PR

This PR enables eCapture’s existing BoringSSL label-based keylog hook on Linux by expanding symbol discovery, without changing the BPF extraction code.

Changes:

  • Adds ordinary ELF symbols and local GNU debug companions alongside Android mini-debug support.
  • Validates companion filenames, read limits, and CRCs while retaining the existing handshake fallback.
  • Adds fixture-based tests for supported symbol sources and invalid or missing companions.
File Description
internal/​probe/​openssl/​config.go Enables keylog-hook discovery for Linux BoringSSL in applicable capture modes.
internal/​probe/​openssl/​boringssl_symbol.go Expands symbol resolution and adds validated GNU debug-companion lookup.
internal/​probe/​openssl/​boringssl_symbol_test.go Tests ordinary, split-debug, and mini-debug symbols plus companion rejection cases.

Review effort: Balanced

Comment on lines +53 to +55
section := lib.Section(".gnu_debugdata")
if section == nil {
debugData, err = boringSSLDebugLink(lib, path)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

a093835 removes the GNU debug-link companion search, so this path is gone. The resolver now reads the ordinary ELF symbol table and then Android's .gnu_debugdata.

Comment on lines +138 to +142
candidates := []string{
filepath.Join(filepath.Dir(path), name),
filepath.Join(filepath.Dir(path), ".debug", name),
filepath.Join("/usr/lib/debug", filepath.Dir(absolute), name),
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

a093835 removes the GNU debug-link companion search, so this path is gone. The resolver now reads the ordinary ELF symbol table and then Android's .gnu_debugdata.

Remove the GNU debug-link companion search. An unstripped Linux library
exposes ssl_log_secret in its ordinary symbol table; stripped libraries
keep Android's .gnu_debugdata path or the SSL_do_handshake fallback.

@cfc4n cfc4n left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, Thanks.

@cfc4n
cfc4n merged commit 52b5fe9 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