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
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ embarass pip index versions pip --index-url=https://pypi.org/simple --no-cache-d
embarass docker manifest inspect docker.io/library/alpine:latest
embarass crane manifest registry.k8s.io/pause:3.10

# Test the direct eMudhra trust path instead of the default Sectigo path
# Test one trust path for fewer runs with narrower coverage
embarass --chain emsign -- curl https://example.com/

# Allow a command to run without the default 30-second deadline
Expand All @@ -94,7 +94,9 @@ embarass --headless -- curl https://example.com/
embarass batch
```

The default test uses the weak `emSign DV TLS CA - G3B` key in its cross-certificate issued by `AAA Certificate Services`. Run a second, explicit test with `--chain emsign` to exercise the direct eMudhra path. `emBarrass` never runs a command twice automatically because the command may have side effects.
By default (`--chain all`), the command tests both trust paths for the weak `emSign DV TLS CA - G3B` key: first the direct eMudhra path to `emSign ECC Root CA - G3`, then the cross-certificate issued by `AAA Certificate Services`. Testing stops with a **vulnerable** result as soon as any path is accepted. The result is **rejected** only if every path is rejected; otherwise it is **inconclusive**.

Testing one path can miss a vulnerable client. Mozilla-derived trust stores trust `AAA Certificate Services` for e-mail only, so a client can reject the Sectigo path but accept the direct path. If both paths run, the command's side effects happen twice. Use `--chain emsign` or `--chain sectigo` to test one path. `--timeout` applies per path.

The default output is an interactive, human-readable terminal report with distinct vulnerable, rejected, inconclusive, and harness-error panels. Use `--headless` to retain the compact one-line log format for automation and captured logs. Both modes use the same exit codes.

Expand All @@ -114,9 +116,9 @@ current image:
cgr.dev/chainguard/git@sha256:06119871a608d163eac2daddd0745582e457a29ee8402bd351c13f294ede30e1
```

Use `embarass batch --chain emsign` to exercise the vulnerable direct eMudhra
trust path in this historical fixture. The default `sectigo` run tests the
separate cross-signed path, which this image's CA bundle need not trust.
By default, `batch` tests both trust paths per probe unless the first is accepted.
The historical `docker/git` fixture is vulnerable through the direct eMudhra
path; its CA bundle need not trust the cross-signed path.

Before anything runs, the terminal UI shows the exact read-only command
selected for each installed tool and marks missing tools as skipped. The prompt
Expand Down Expand Up @@ -150,7 +152,7 @@ For automation, make consent explicit and select compact output:

```console
embarass batch --yes --headless
embarass batch --yes --headless --chain emsign
embarass batch --yes --headless --chain emsign # one trust path per probe
```

The batch exits `1` if any tool is vulnerable, `2` if none are vulnerable but
Expand All @@ -168,10 +170,10 @@ Git can use `url.*.insteadOf` configuration to silently rewrite an explicit HTTP
| Exit | Result | Meaning |
|---:|---|---|
| `1` | **Vulnerable** | The child accepted the forged chain and sent application data. `emBarrass` immediately terminated the child. |
| `0` | **Not confirmed / rejected** | The child reached `emBarrass` but rejected or otherwise failed the forged TLS handshake. |
| `0` | **Not confirmed / rejected** | On every tested trust path, the child reached `emBarrass` but rejected or otherwise failed the forged TLS handshake. |
| `2` | **Inconclusive or harness error** | No HTTPS proxy traffic was observed, no TLS decision was reached, the deadline expired, or the harness failed. |

A zero exit is evidence about the tested executable, machine, trust state, and selected chain—not a permanent verdict about a product family. Use both trust paths for broader coverage.
A zero exit is evidence about the tested executable, machine, trust state, and trust paths—not a permanent verdict about a product family.

## How it works

Expand Down
31 changes: 15 additions & 16 deletions cmd/embarass/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ immutable, digest-pinned image.`,
},
}
command.Flags().BoolVarP(&app.batchYes, "yes", "y", false, "run the displayed probes without prompting")
command.Flags().DurationVar(&app.timeout, "timeout", defaultTimeout, "maximum runtime per tool; 0 disables the deadline")
command.Flags().StringVar(&app.chain, "chain", string(certforge.ChainSectigo), "trust path to test: sectigo or emsign")
command.Flags().DurationVar(&app.timeout, "timeout", defaultTimeout, "maximum runtime per tool and trust path; 0 disables the deadline")
command.Flags().StringVar(&app.chain, "chain", chainAll, chainFlagUsage)
command.Flags().BoolVar(&app.headless, "headless", false, "emit compact log lines without the terminal UI")
command.Flags().BoolVarP(&app.verbose, "verbose", "v", false, "enable debug logging")
return command
Expand All @@ -51,7 +51,7 @@ func (app *application) runBatch(cmd *cobra.Command) error {
if app.timeout < 0 {
return fmt.Errorf("timeout must not be negative: %s", app.timeout)
}
chain, err := parseChain(app.chain)
chains, err := parseChains(app.chain)
if err != nil {
return err
}
Expand Down Expand Up @@ -79,9 +79,9 @@ func (app *application) runBatch(cmd *cobra.Command) error {

var summary batchSummary
if app.headless || !interactive {
summary = app.runBatchHeadless(cmd.Context(), plan, chain)
summary = app.runBatchHeadless(cmd.Context(), plan, chains)
} else {
summary, err = app.runBatchTerminal(cmd, plan, chain)
summary, err = app.runBatchTerminal(cmd, plan, chains)
}
cleanupErr := plan.Cleanup()
if err != nil || cleanupErr != nil {
Expand All @@ -94,7 +94,7 @@ func (app *application) runBatch(cmd *cobra.Command) error {
func (app *application) runBatchTerminal(
cmd *cobra.Command,
plan batchtest.Plan,
chain certforge.Chain,
chains []certforge.Chain,
) (batchSummary, error) {
ctx, cancel := context.WithCancel(cmd.Context())
defer cancel()
Expand All @@ -104,8 +104,7 @@ func (app *application) runBatchTerminal(
cancel,
newTerminalUI(cmd.ErrOrStderr()).styles,
plan,
app.run,
chain,
acrossChains(app.run, chains),
app.timeout,
app.batchYes,
)
Expand All @@ -129,7 +128,7 @@ func (app *application) runBatchTerminal(
func (app *application) runBatchHeadless(
ctx context.Context,
plan batchtest.Plan,
chain certforge.Chain,
chains []certforge.Chain,
) batchSummary {
log := zerolog.Ctx(ctx)
available := make([]string, 0, len(plan.Probes))
Expand All @@ -147,9 +146,9 @@ func (app *application) runBatchHeadless(
summary := batchSummary{skipped: len(plan.Unavailable)}
for _, probe := range plan.Probes {
log.Info().Str("tool", probe.Name).Str("command", probe.Preview).Msg("testing TLS trust")
result, err := app.run(ctx, batchRunnerOptions(plan, probe, chain, app.timeout))
result, reportedChains, err := runChains(ctx, app.run, batchRunnerOptions(plan, probe, app.timeout), chains, nil)
summary.record(result, err)
logBatchResult(log, probe.Name, result, err)
logBatchResult(log, probe.Name, result, reportedChains, err)
}
log.Info().
Int("embarrassed", summary.vulnerable).
Expand All @@ -173,7 +172,6 @@ func planMayPullImage(plan batchtest.Plan) bool {
func batchRunnerOptions(
plan batchtest.Plan,
probe batchtest.Probe,
chain certforge.Chain,
timeout time.Duration,
) runner.Options {
proxyTarget := runner.ProxyTargetHost
Expand All @@ -185,29 +183,30 @@ func batchRunnerOptions(
Timeout: timeout,
Stdout: io.Discard,
Stderr: io.Discard,
Chain: chain,
WorkingDirectory: plan.WorkingDirectory(),
EnvironmentOverrides: probe.EnvironmentOverrides,
ProxyTarget: proxyTarget,
}
}

func logBatchResult(log *zerolog.Logger, tool string, result runner.Result, err error) {
func logBatchResult(log *zerolog.Logger, tool string, result runner.Result, chains []certforge.Chain, err error) {
if err != nil {
log.Error().Err(err).Str("tool", tool).Msg("HARNESS ERROR")
return
}
event := log.Info().Str("tool", tool).Str("host", result.Host).Dur("duration", result.Duration)
chain := chainNames(chains, ",")
event := log.Info().Str("tool", tool).Str("host", result.Host).Str("chain", chain).Dur("duration", result.Duration)
switch result.Outcome {
case runner.OutcomeVulnerable:
event = log.Error().Str("tool", tool).Str("host", result.Host).Dur("duration", result.Duration)
event = log.Error().Str("tool", tool).Str("host", result.Host).Str("chain", chain).Dur("duration", result.Duration)
event.Msg("COMPLETELY EMBARRASSED: forged certificate accepted")
case runner.OutcomeRejected:
event.Msg("TRUST HELD: forged certificate rejected")
case runner.OutcomeInconclusive:
log.Warn().
Str("tool", tool).
Str("reason", string(result.Reason)).
Str("chain", chain).
Dur("duration", result.Duration).
Msg("NO SIGNAL: result inconclusive")
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/embarass/batch_terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/boostsecurityio/emBarrass/pkg/batchtest"
"github.com/boostsecurityio/emBarrass/pkg/certforge"
"github.com/boostsecurityio/emBarrass/pkg/runner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
Expand Down Expand Up @@ -46,7 +45,6 @@ type batchModel struct {
styles terminalStyles
plan batchtest.Plan
run runFunc
chain certforge.Chain
timeout time.Duration
items []batchItem
current int
Expand All @@ -72,7 +70,6 @@ func newBatchModel(
styles terminalStyles,
plan batchtest.Plan,
run runFunc,
chain certforge.Chain,
timeout time.Duration,
autoStart bool,
) batchModel {
Expand All @@ -86,7 +83,6 @@ func newBatchModel(
styles: styles,
plan: plan,
run: run,
chain: chain,
timeout: timeout,
items: items,
width: 80,
Expand Down Expand Up @@ -171,7 +167,7 @@ func (model batchModel) runCurrent() tea.Cmd {
return func() tea.Msg {
result, err := model.run(
model.ctx,
batchRunnerOptions(model.plan, probe, model.chain, model.timeout),
batchRunnerOptions(model.plan, probe, model.timeout),
)
return batchResultMsg{index: index, result: result, err: err}
}
Expand Down
7 changes: 1 addition & 6 deletions cmd/embarass/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/boostsecurityio/emBarrass/pkg/batchtest"
"github.com/boostsecurityio/emBarrass/pkg/certforge"
"github.com/boostsecurityio/emBarrass/pkg/runner"
tea "github.com/charmbracelet/bubbletea"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -50,7 +49,6 @@ func TestBatchModelPreviewsThenRunsConfirmedProbe(t *testing.T) {
ui.styles,
plan,
run,
certforge.ChainSectigo,
30*time.Second,
false,
)
Expand Down Expand Up @@ -91,7 +89,6 @@ func TestBatchModelDefaultsToCancel(t *testing.T) {
t.Fatal("probe must not run before confirmation")
return runner.Result{}, errors.New("unreachable")
},
certforge.ChainSectigo,
30*time.Second,
false,
)
Expand Down Expand Up @@ -121,12 +118,11 @@ func TestBatchRunnerOptionsIsolateWritesAndDiscardOutput(t *testing.T) {
"GOCACHE": filepath.Join(workspace, "go-build"),
},
}
options := batchRunnerOptions(plan, probe, certforge.ChainEMSign, 5*time.Second)
options := batchRunnerOptions(plan, probe, 5*time.Second)

require.Equal(t, probe.Command(), options.Command)
require.Equal(t, probe.EnvironmentOverrides, options.EnvironmentOverrides)
require.Equal(t, plan.WorkingDirectory(), options.WorkingDirectory)
require.Equal(t, certforge.ChainEMSign, options.Chain)
require.Equal(t, 5*time.Second, options.Timeout)
require.Equal(t, runner.ProxyTargetDockerContainer, options.ProxyTarget)
}
Expand All @@ -137,7 +133,6 @@ func TestBatchRunnerOptionsDefaultToHostProxy(t *testing.T) {
options := batchRunnerOptions(
batchtest.Plan{},
batchtest.Probe{Name: "curl", Executable: "/usr/bin/curl"},
certforge.ChainSectigo,
time.Second,
)

Expand Down
102 changes: 102 additions & 0 deletions cmd/embarass/chains.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright (C) 2026 boostsecurity.io
// SPDX-License-Identifier: GPL-3.0-or-later

package main

import (
"context"
"fmt"
"strings"
"time"

"github.com/boostsecurityio/emBarrass/pkg/certforge"
"github.com/boostsecurityio/emBarrass/pkg/runner"
"github.com/rs/zerolog"
)

// Testing one path can miss clients that trust the compromised key through another.
const chainAll = "all"

// emSign runs first because current Mozilla-derived stores trust it for TLS,
// allowing vulnerable clients to stop after one run.
var allChains = []certforge.Chain{certforge.ChainEMSign, certforge.ChainSectigo}

const chainFlagUsage = "trust path to test: all, sectigo, or emsign"

func parseChains(value string) ([]certforge.Chain, error) {
switch chain := certforge.Chain(strings.ToLower(value)); chain {
case chainAll:
return allChains, nil
case certforge.ChainSectigo, certforge.ChainEMSign:
return []certforge.Chain{chain}, nil
default:
return nil, fmt.Errorf("unsupported chain %q: use all, sectigo, or emsign", value)
}
}

// runChains stops at the first accepted path. It reports rejection only if all
// paths reject, and inconclusive otherwise. The returned paths identify the
// result; an inconclusive result names only the path its reason and child exit
// came from. beforePath, if set, runs before each path so callers can separate
// the child output of consecutive runs.
func runChains(
ctx context.Context,
run runFunc,
options runner.Options,
chains []certforge.Chain,
beforePath func(certforge.Chain),
) (runner.Result, []certforge.Chain, error) {
var (
reported runner.Result
reportedChain certforge.Chain
elapsed time.Duration
)
for _, chain := range chains {
// Do not start another child, and repeat its side effects, after cancellation.
if ctx.Err() != nil {
return runner.Result{}, nil, fmt.Errorf("test %s trust path: %w", chain, context.Cause(ctx))
}
zerolog.Ctx(ctx).Debug().Str("chain", string(chain)).Msg("Testing trust path")
if beforePath != nil {
beforePath(chain)
}
options.Chain = chain
result, err := run(ctx, options)
if err != nil {
return runner.Result{}, nil, fmt.Errorf("test %s trust path: %w", chain, err)
}
elapsed += result.Duration
switch result.Outcome {
case runner.OutcomeVulnerable:
result.Duration = elapsed
return result, []certforge.Chain{chain}, nil
case runner.OutcomeRejected, runner.OutcomeInconclusive:
if reported.Outcome != runner.OutcomeInconclusive {
reported, reportedChain = result, chain
}
default:
return result, []certforge.Chain{chain}, nil
}
}
reported.Duration = elapsed
if reported.Outcome == runner.OutcomeInconclusive {
return reported, []certforge.Chain{reportedChain}, nil
}
return reported, chains, nil
}

// acrossChains overrides Options.Chain to give batch probes the same path coverage.
func acrossChains(run runFunc, chains []certforge.Chain) runFunc {
return func(ctx context.Context, options runner.Options) (runner.Result, error) {
result, _, err := runChains(ctx, run, options, chains, nil)
return result, err
}
}

func chainNames(chains []certforge.Chain, separator string) string {
names := make([]string, 0, len(chains))
for _, chain := range chains {
names = append(names, string(chain))
}
return strings.Join(names, separator)
}
Loading
Loading