Skip to content
Draft
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
51 changes: 51 additions & 0 deletions .github/workflows/protected-control-crossuid-rdte.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Real Cross-UID Protected Control Negative RDTE

on:
pull_request:
paths:
- 'rdte/protected-control/cross_uid_test.go'
- '.github/workflows/protected-control-crossuid-rdte.yml'

permissions:
contents: read

jobs:
isolated-linux-uid-negative:
runs-on: ubuntu-24.04
timeout-minutes: 12
steps:
- name: Checkout exact disposable public source
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Compile Linux Go test binary with no extra modules
shell: bash
run: |
set -euo pipefail
GO111MODULE=off go test -c -o "$RUNNER_TEMP/winebot-control-crossuid.test" ./rdte/protected-control
test -x "$RUNNER_TEMP/winebot-control-crossuid.test"
echo 'CROSS_UID_RDTE stage=compiled'
- name: Deny numeric guest UID 1000 even when synthetic socket is readable
shell: bash
env:
DOCKER_BUILD_RECORD_UPLOAD: 'false'
run: |
set -euo pipefail
# Root is only inside the unprivileged, networkless, disposable OCI
# test container. Capabilities are limited to SETUID/SETGID to create
# a distinct numeric-UID child; no host control mounts or secrets.
image='debian@sha256:cedb1ef40439206b673ee8b33a46a03a0c9fa90bf3732f54704f99cb061d2c5a'
if ! docker run --rm --network none --read-only \
--cap-drop ALL --cap-add SETUID --cap-add SETGID \
--security-opt no-new-privileges --pids-limit 128 \
--memory 512m --tmpfs /tmp:rw,nosuid,nodev,mode=1777,size=32m \
-e GOMAXPROCS=2 \
-v "$RUNNER_TEMP/winebot-control-crossuid.test:/usr/local/bin/crossuid.test:ro" \
--entrypoint /usr/local/bin/crossuid.test "$image" \
-test.run '^TestRealCrossUIDGuestDeniedEvenWhenSocketDACPermissive$' \
>/dev/null 2>&1; then
echo 'CROSS_UID_RDTE stage=failed'
exit 1
fi
echo 'CROSS_UID_RDTE stage=real_numeric_uid_denied'
22 changes: 22 additions & 0 deletions rdte/protected-control/CROSS_UID_NEGATIVE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Independent actual cross-UID negative — R040

Source adds a separate Docker-only test to the protected-control reference.
A root-credential controller binds its synthetic Unix socket under a freshly
created /tmp directory. The test alone deliberately changes the temporary
directory/socket modes to permit numeric UID1000 to connect. A child test
process drops to UID/GID1000 using CAP_SETUID/CAP_SETGID confined to an
otherwise cap-dropped, networkless, read-only disposable Docker container.

The child must successfully establish the socket connection and receive
the fixed CONTROL_IPC=DENIED marker from kernel SO_PEERCRED authentication.
The root owner record must remain nonexistent. The probe uses neither an
actual WineBot mount, actual application, nor user secrets. Raw fixture
paths and child output are not printed in CI, and the test image is pinned
by digest with no image publication.

This qualifies a *single Linux namespace* numeric-UID mismatch only.
It does NOT prove cross-user-namespace mapped credentials, authenticated
runtime IPC, guest-vs-API principal separation, mount custody, host root
security, operation audit, or crash-safe socket re-admission. Production
WineBot still exposes its writer lock under UID1000-writable artifacts;
the release STOP remains.
83 changes: 83 additions & 0 deletions rdte/protected-control/cross_uid_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//go:build linux

package main

import (
"errors"
"io"
"net"
"os"
"os/exec"
"path/filepath"
"syscall"
"testing"
"time"
)

// Executed only from a separate numeric-UID guest child in the isolated
// disposable Docker test. Never reads a WineBot production mount.
func TestSyntheticGuestSocketClient(t *testing.T){
if os.Getenv("WINEBOT_SYNTHETIC_GUEST")!="1"{return}
if os.Geteuid()!=1000||os.Getegid()!=1000{t.Fatal("guest identity invalid")}
path:=os.Getenv("WINEBOT_SYNTHETIC_SOCKET")
if !filepath.IsAbs(path){t.Fatal("socket fixture invalid")}
c,err:=net.DialTimeout("unix",path,2*time.Second)
if err!=nil{t.Fatal("guest could not reach deliberately exposed fixture")}
defer c.Close()
_=c.SetDeadline(time.Now().Add(2*time.Second))
_,err=c.Write([]byte("{\"op\":\"claim\",\"session_id\":\"guest\",\"expected_generation\":0,\"operation_id\":\"forged\"}"))
if err!=nil{t.Fatal("guest send failed")}
conn,ok:=c.(*net.UnixConn)
if !ok{t.Fatal("guest transport invalid")}
if err=conn.CloseWrite();err!=nil{t.Fatal("guest half-close failed")}
reply,err:=io.ReadAll(io.LimitReader(c,256))
if err!=nil{t.Fatal("guest denial unreadable")}
if string(reply)!="CONTROL_IPC=DENIED\n"{t.Fatal("kernel rejected credential proof absent")}
}

// Requires only a root process INSIDE a private OCI container permitted
// CAP_SETUID/GID; tests run against fresh synthetic /tmp state.
func TestRealCrossUIDGuestDeniedEvenWhenSocketDACPermissive(t *testing.T){
if os.Geteuid()!=0{t.Skip("Docker-only root test")}
root,err:=os.MkdirTemp("/tmp","winebot-synthetic-peer-")
if err!=nil{t.Fatal("fixture create failed")}
defer os.RemoveAll(root)
if err=os.Chmod(root,0700);err!=nil{t.Fatal("fixture permissions failed")}
listener,err:=listenControl(root,0)
if err!=nil{t.Fatal("root control listener unavailable")}
defer listener.Close()
// Deliberately weaken DAC ONLY inside this synthetic tempdir. A guest
// must actually connect, then be rejected by kernel SO_PEERCRED, proving
// broker authorization is independent of filesystem access.
socket:=filepath.Join(root,socketName)
if err=os.Chmod(root,0755);err!=nil{t.Fatal("fixture expose failed")}
if err=os.Chmod(socket,0666);err!=nil{t.Fatal("socket fixture expose failed")}
complete:=make(chan error,1)
go func(){
c,err:=listener.AcceptUnix()
if err==nil{handleControlConn(c,root,0,0,0)}
complete<-err
}()
child:=exec.Command(os.Args[0],"-test.run=^TestSyntheticGuestSocketClient$")
child.Env=append(os.Environ(),
"WINEBOT_SYNTHETIC_GUEST=1",
"WINEBOT_SYNTHETIC_SOCKET="+socket,
)
child.SysProcAttr=&syscall.SysProcAttr{
Credential:&syscall.Credential{Uid:1000,Gid:1000},
}
output,err:=child.CombinedOutput()
_=output // No guest-controlled output or synthetic socket path published.
if err!=nil{t.Fatal("separate guest process failed negative probe")}
select{
case err:=<-complete:
if err!=nil{t.Fatal("control accept failed")}
case <-time.After(4*time.Second):
t.Fatal("control broker stalled on guest identity")
}
if _,err:=os.Lstat(filepath.Join(root,ownerName));!errors.Is(err,os.ErrNotExist){
t.Fatal("unauthorized guest modified owner state")
}
if err=os.Chmod(socket,0600);err!=nil{t.Fatal("socket fixture restoration failed")}
if err=os.Chmod(root,0700);err!=nil{t.Fatal("directory fixture restoration failed")}
}