Skip to content
Open
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
21 changes: 21 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Runtime security checks

on:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
security:
strategy:
fail-fast: false
matrix:
runner: [ubuntu-latest, ubuntu-24.04-arm]
runs-on: ${{ matrix.runner }}
timeout-minutes: 35
steps:
- uses: actions/checkout@v4
- name: Build and check runtimes, trust stores, tracker, signer and migrations
run: python3 tests/security.py
38 changes: 37 additions & 1 deletion services/flyway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
FROM alpine:3.15.10 as migrations-download
FROM alpine:3.24 AS ca-trust
RUN apk add --no-cache 'ca-certificates>=20261020' 'ca-certificates-bundle>=20261020'

FROM ca-trust AS java-ca-helper
RUN apk add --no-cache openjdk21-jdk
COPY RemoveDistrustedRoots.java /tmp/
RUN mkdir -p /opt/ca-trust && javac --release 11 -d /opt/ca-trust /tmp/RemoveDistrustedRoots.java

FROM ca-trust AS migrations-download
ARG WEB3SIGNER_VERSION
WORKDIR /usr/src/app

# Copy files in branch ${WEB3SIGNER_VERSION} from web3signer repository
RUN apk --no-cache add git && \
git clone --depth 1 --branch ${WEB3SIGNER_VERSION} https://github.com/ConsenSys/web3signer.git

FROM ca-trust AS patched-java
ARG TARGETARCH
RUN apk add --no-cache curl
RUN case "${TARGETARCH}" in \
amd64) url="https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.13%2B9/OpenJDK21U-jre_x64_alpine-linux_hotspot_21.0.13_9.tar.gz"; sha="9138eab0f7d230e17163953f015ec9ae2431dbc49069c658b7f991e45b54fb9b" ;; \
arm64) url="https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.13%2B9/OpenJDK21U-jre_aarch64_alpine-linux_hotspot_21.0.13_9.tar.gz"; sha="382633eb2ba28cc5b97be1446eb1dd8d2a60a3795be0166a030e4cda338c490e" ;; \
*) echo "Unsupported Java architecture: ${TARGETARCH}" >&2; exit 1 ;; \
esac && \
curl --fail --location --retry 3 "$url" -o /tmp/jre.tar.gz && \
echo "$sha /tmp/jre.tar.gz" | sha256sum -c - && \
mkdir /jre && tar -xzf /tmp/jre.tar.gz --strip-components=1 -C /jre && \
rm /tmp/jre.tar.gz

FROM flyway/flyway:11.10-alpine
USER root
RUN rm -rf /opt/java/openjdk
COPY --from=patched-java /jre/ /opt/java/openjdk/
ENV JAVA_HOME=/opt/java/openjdk JAVA_VERSION=jre-21.0.13+9
ENV PATH="${JAVA_HOME}/bin:${PATH}"


ARG NETWORK
ARG PGPASSWORD
Expand All @@ -29,3 +56,12 @@ COPY --from=migrations-download /usr/src/app/web3signer/slashing-protection/src/
RUN apk update && apk --no-cache add postgresql-client

ENTRYPOINT ["entrypoint.sh"]

# Refresh all OS trust files, then clean Java's independent default keystore.
RUN rm -rf /etc/ssl/certs /usr/share/ca-certificates
COPY --from=ca-trust /etc/ssl/certs/ /etc/ssl/certs/
COPY --from=ca-trust /usr/share/ca-certificates/ /usr/share/ca-certificates/
COPY --from=ca-trust /etc/ca-certificates.conf /etc/ca-certificates.conf
RUN ln -sf certs/ca-certificates.crt /etc/ssl/cert.pem
COPY --from=java-ca-helper /opt/ca-trust/ /tmp/ca-trust/
RUN java -cp /tmp/ca-trust RemoveDistrustedRoots && rm -rf /tmp/ca-trust
62 changes: 62 additions & 0 deletions services/flyway/RemoveDistrustedRoots.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import javax.naming.ldap.LdapName;
import javax.naming.ldap.Rdn;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;

/** Remove compromised CA trust paths by public key, independently of alias names. */
public final class RemoveDistrustedRoots {
private static final Set<String> BLOCKED = Set.of(
"bd153ed7b0434f6886b17bce8bbe84ed340c7132d702a8f4fa318f756ecbd6f3",
"c619e4780ed8e0abeda24ad732567de4383a7ea941338f6d1a7d1b49ac792fe9",
"8d417db2dd8bf5e3084d1e3f196d583849d81bdd4c00c70b9d39369e96b8c782");

// Oracle's current mitigation includes all four roots, including G1/G2.
private static final Set<String> BLOCKED_COMMON_NAMES = Set.of(
"emSign ECC Root CA - G3", "AAA Certificate Services",
"emSign Root CA - G1", "emSign Root CA - G2");

public static void main(String[] args) throws Exception {
Path path = args.length == 0
? Path.of(System.getProperty("java.home"), "lib", "security", "cacerts")
: Path.of(args[0]);
char[] password = "changeit".toCharArray();
KeyStore store = KeyStore.getInstance(path.toFile(), password);
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
ArrayList<String> removed = new ArrayList<>();
for (String alias : Collections.list(store.aliases())) {
Certificate certificate = store.getCertificate(alias);
if (certificate == null) continue;
byte[] digest = sha256.digest(certificate.getPublicKey().getEncoded());
StringBuilder hex = new StringBuilder();
for (byte b : digest) hex.append(String.format("%02x", b & 0xff));
boolean blockedName = false;
if (certificate instanceof X509Certificate) {
X509Certificate x509 = (X509Certificate) certificate;
for (Rdn rdn : new LdapName(x509.getSubjectX500Principal().getName()).getRdns()) {
if ("CN".equalsIgnoreCase(rdn.getType()) && BLOCKED_COMMON_NAMES.contains(rdn.getValue().toString())) {
blockedName = true;
}
}
}
if (BLOCKED.contains(hex.toString()) || blockedName) {
store.deleteEntry(alias);
removed.add(alias);
}
}
if (store.size() < 80) throw new IllegalStateException("Unexpectedly small trust store");
if (!removed.isEmpty()) {
try (OutputStream output = Files.newOutputStream(path)) {
store.store(output, password);
}
}
System.out.println("Removed distrusted Java roots: " + removed.size());
}
}
27 changes: 25 additions & 2 deletions services/tracker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
ARG TRACKER_VERSION

FROM golang:1.27.3-alpine3.24 AS patched-go
ARG TRACKER_VERSION
# Update this pin together with TRACKER_VERSION.
ARG TRACKER_COMMIT=1c2c8076710bfc59e4958d226130ecc191a4222c
ENV GOTOOLCHAIN=local GOMAXPROCS=2 GOFLAGS=-p=2 GOMEMLIMIT=1500MiB
RUN apk add --no-cache git 'ca-certificates>=20261020'
WORKDIR /src
RUN git clone --depth 1 --branch "${TRACKER_VERSION}" https://github.com/dappnode/validator-tracker.git . && \
test "$(git rev-parse HEAD)" = "${TRACKER_COMMIT}"
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 go build -trimpath -o /out/validator-tracker ./cmd/main.go

FROM alpine:3.24 AS ca-trust
RUN apk add --no-cache 'ca-certificates>=20261020' 'ca-certificates-bundle>=20261020'

FROM ghcr.io/dappnode/validator-tracker:${TRACKER_VERSION}
COPY --from=patched-go /out/validator-tracker /app/validator-tracker
RUN rm -rf /etc/ssl/certs /usr/share/ca-certificates
COPY --from=ca-trust /etc/ssl/certs/ /etc/ssl/certs/
COPY --from=ca-trust /usr/share/ca-certificates/ /usr/share/ca-certificates/
COPY --from=ca-trust /etc/ca-certificates.conf /etc/ca-certificates.conf
RUN ln -sf certs/ca-certificates.crt /etc/ssl/cert.pem

ARG NETWORK

ENV NETWORK=${NETWORK}
# Ordinary TCP remains available; the host still needs its kernel security update.
ENV NETWORK=${NETWORK} GODEBUG=multipathtcp=0
17 changes: 17 additions & 0 deletions services/web3signer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
ARG WEB3SIGNER_VERSION

FROM alpine:3.24 AS ca-trust
RUN apk add --no-cache 'ca-certificates>=20261020' 'ca-certificates-bundle>=20261020'

FROM ca-trust AS java-ca-helper
RUN apk add --no-cache openjdk21-jdk
COPY RemoveDistrustedRoots.java /tmp/
RUN mkdir -p /opt/ca-trust && javac --release 11 -d /opt/ca-trust /tmp/RemoveDistrustedRoots.java

FROM consensys/web3signer:$WEB3SIGNER_VERSION

ARG NETWORK
Expand Down Expand Up @@ -28,3 +36,12 @@ ENV NETWORK=${NETWORK} \
POSTGRES_USER=${POSTGRES_USER}

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

# Refresh all OS trust files, then clean Java's independent default keystore.
RUN rm -rf /etc/ssl/certs /usr/share/ca-certificates
COPY --from=ca-trust /etc/ssl/certs/ /etc/ssl/certs/
COPY --from=ca-trust /usr/share/ca-certificates/ /usr/share/ca-certificates/
COPY --from=ca-trust /etc/ca-certificates.conf /etc/ca-certificates.conf
RUN ln -sf certs/ca-certificates.crt /etc/ssl/cert.pem
COPY --from=java-ca-helper /opt/ca-trust/ /tmp/ca-trust/
RUN java -cp /tmp/ca-trust RemoveDistrustedRoots && rm -rf /tmp/ca-trust
62 changes: 62 additions & 0 deletions services/web3signer/RemoveDistrustedRoots.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import javax.naming.ldap.LdapName;
import javax.naming.ldap.Rdn;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;

/** Remove compromised CA trust paths by public key, independently of alias names. */
public final class RemoveDistrustedRoots {
private static final Set<String> BLOCKED = Set.of(
"bd153ed7b0434f6886b17bce8bbe84ed340c7132d702a8f4fa318f756ecbd6f3",
"c619e4780ed8e0abeda24ad732567de4383a7ea941338f6d1a7d1b49ac792fe9",
"8d417db2dd8bf5e3084d1e3f196d583849d81bdd4c00c70b9d39369e96b8c782");

// Oracle's current mitigation includes all four roots, including G1/G2.
private static final Set<String> BLOCKED_COMMON_NAMES = Set.of(
"emSign ECC Root CA - G3", "AAA Certificate Services",
"emSign Root CA - G1", "emSign Root CA - G2");

public static void main(String[] args) throws Exception {
Path path = args.length == 0
? Path.of(System.getProperty("java.home"), "lib", "security", "cacerts")
: Path.of(args[0]);
char[] password = "changeit".toCharArray();
KeyStore store = KeyStore.getInstance(path.toFile(), password);
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
ArrayList<String> removed = new ArrayList<>();
for (String alias : Collections.list(store.aliases())) {
Certificate certificate = store.getCertificate(alias);
if (certificate == null) continue;
byte[] digest = sha256.digest(certificate.getPublicKey().getEncoded());
StringBuilder hex = new StringBuilder();
for (byte b : digest) hex.append(String.format("%02x", b & 0xff));
boolean blockedName = false;
if (certificate instanceof X509Certificate) {
X509Certificate x509 = (X509Certificate) certificate;
for (Rdn rdn : new LdapName(x509.getSubjectX500Principal().getName()).getRdns()) {
if ("CN".equalsIgnoreCase(rdn.getType()) && BLOCKED_COMMON_NAMES.contains(rdn.getValue().toString())) {
blockedName = true;
}
}
}
if (BLOCKED.contains(hex.toString()) || blockedName) {
store.deleteEntry(alias);
removed.add(alias);
}
}
if (store.size() < 80) throw new IllegalStateException("Unexpectedly small trust store");
if (!removed.isEmpty()) {
try (OutputStream output = Files.newOutputStream(path)) {
store.store(output, password);
}
}
System.out.println("Removed distrusted Java roots: " + removed.size());
}
}
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
47 changes: 47 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Runtime security validation

The security update retains Web3Signer 26.10.2 and Brain 0.1.33. It rebuilds
Validator Tracker 0.1.5 from commit `1c2c8076710bfc59e4958d226130ecc191a4222c`
with Go 1.27.3, upgrades Flyway's Java runtime to Temurin 21.0.13+9, refreshes
the three affected services' OS trust files, and removes the four roots listed
in [Oracle's current mitigation](https://ops.java/emudhra) from both Java stores.
The main signer's existing Java 25.0.5+8 runtime is retained.

Run from the repository root with Docker Compose v2, Python 3 and OpenSSL:

```sh
python3 tests/security.py
```

This builds the three changed services for the mainnet variant and checks:

- All four variants' Compose configuration.
- The compiled Tracker Go version and its default `GODEBUG=multipathtcp=0`.
- OS certificate bundles against the incident's three blocked public-key hashes.
- Java runtime versions and all four distrusted root names in the actual default stores.
- JKS and PKCS12 cleanup with unrelated aliases, preservation of an unrelated root,
idempotency, and rejection of an implausibly small trust store.
- Tracker initialization against a mock beacon and successful initialization after restart.
- The real signer health/public-key APIs with an empty key directory, before and after restart.
- Fresh slashing-protection migrations on PostgreSQL 14 and a repeated no-op migration.

Application fixtures run on a disposable internal Docker network without published
ports, production volumes, validator keys or external notification endpoints. Test
containers and their anonymous volumes are removed on exit. Builds download public
dependencies. The signer smoke test disables slashing protection only for its empty-key
API fixture; it is separate from the Flyway/database migration test and does not prove
full production signer/database integration or an existing database upgrade.

CI runs these checks on native amd64 and ARM64 runners. To reuse images already built
with a specific Compose project name:

```sh
python3 tests/security.py --project web3signer-security --skip-build
```

Update `TRACKER_COMMIT` alongside `TRACKER_VERSION` for future upstream bumps. The Go
setting changes the default for new sockets and can be overridden by application code
or operator-supplied environment. It reduces MPTCP exposure; **CVE-2026-98432 still needs
a patched host kernel**. Docker's daemon-owned DNS sockets require separate host/daemon
mitigation. No host sysctl, Docker daemon, PostgreSQL data format or package version is
changed by this PR.
Loading
Loading