mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-12-03 13:11:05 +00:00
Rebased onto main (5f5ec32) and hardened per security review:
- Opt-in only (-shared-browser / ARTEX_SHARED_BROWSER=true; default false); README and CHANGELOG accurately describe hardened behavior and document the residual risk of same-UID argv token visibility alongside per-message operator-hold/lease enforcement and immediate revocation.
- Isolates CDP via --remote-debugging-pipe on Unix (no Chromium DevTools TCP port or DevToolsActivePort) fronted by a per-run 256-bit token-authenticated server CDP proxy enforcing operator hold and active lease on every HTTP request and WebSocket message.
- Removes --ignore-certificate-errors from the capture path; trusts only ARTEX's capture CA SPKI pin (--ignore-certificate-errors-spki-list) and fails closed if unreadable.
- Removes --disable-blink-features=AutomationControlled and the HeadlessChrome user-agent rewrite (policy: hand challenges off via ask_operator).
- Isolates browser profiles per task or chat session under <data>/browser-profiles/<scope> using descriptor-relative openat(O_NOFOLLOW|O_DIRECTORY) + fchown + unlinkat with root-owned parent (no filepath.Walk over executor-owned trees), tested against root/scope/child symlinks.
- Makes operator lock / ask_operator hold timeout configurable via -shared-browser-lock-timeout / ARTEX_SHARED_BROWSER_LOCK_TIMEOUT (default 15m), auto-expiring idle locks.
Co-authored-by: Pranil Acharya <Pro-Nil@users.noreply.github.com>
37 lines
954 B
Go
37 lines
954 B
Go
//go:build !unix
|
|
|
|
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
var sharedBrowserStaleLockFiles = []string{
|
|
"SingletonLock",
|
|
"SingletonSocket",
|
|
"SingletonCookie",
|
|
"DevToolsActivePort",
|
|
}
|
|
|
|
func prepareSharedBrowserProfileDir(root, scope string, _ ExecPrivilege) (string, error) {
|
|
scope = sanitizeProfileScope(scope)
|
|
if fi, err := os.Lstat(root); err == nil && fi.Mode()&os.ModeSymlink != 0 {
|
|
return "", fmt.Errorf("profile root %q must not be a symlink", root)
|
|
}
|
|
if err := os.MkdirAll(root, 0o700); err != nil {
|
|
return "", err
|
|
}
|
|
profileDir := filepath.Join(root, scope)
|
|
if fi, err := os.Lstat(profileDir); err == nil && fi.Mode()&os.ModeSymlink != 0 {
|
|
return "", fmt.Errorf("profile scope %q must not be a symlink", scope)
|
|
}
|
|
if err := os.MkdirAll(profileDir, 0o700); err != nil {
|
|
return "", err
|
|
}
|
|
for _, f := range sharedBrowserStaleLockFiles {
|
|
_ = os.Remove(filepath.Join(profileDir, f))
|
|
}
|
|
return profileDir, nil
|
|
}
|