Compare commits

..
3 changed files with 94 additions and 81 deletions

No files matched your search

@@ -1,78 +0,0 @@
# study-processes-hunt.yml - hunt scaffolding, never merged. Runs only on a push to a `hunt/study-processes**` branch.
#
# The studies of row 6 of the night plan (13/11) and the Windows sandbox twin: the retail Firefox 159.0 (from archive.mozilla.org)
# and this browser (the published engine through the package) on the same local page, one after the other, on Windows and on Linux:
# the memory of every process by kind, the sandbox of every process (Windows token, Linux seccomp), the names each resolved
# (MOZ_LOG nsHostResolver) and the files of the profile's datareporting/. scripts/study_processes.py; the numbers go to the study
# repository with their run.
name: study processes hunt
on:
push:
branches: ['hunt/study-processes**']
permissions:
contents: read
concurrency:
group: study-processes-hunt-${{ github.ref }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ github.token }}
jobs:
study:
name: study (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
max-parallel: 2
matrix:
os: [windows-2022, ubuntu-24.04]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with: { python-version: '3.11' }
- name: Install the wrapper, the published engine, the retail Firefox 159.0
run: |
set -e
python -m pip install --quiet --upgrade pip
python -m pip install --quiet ".[dev]" psutil
echo "OURS=$(cd "$RUNNER_TEMP" && python -m invisible_playwright fetch | tail -1)" >> "$GITHUB_ENV"
if [ "$RUNNER_OS" = "Windows" ]; then
curl -sSL -o "$RUNNER_TEMP/setup.exe" "https://archive.mozilla.org/pub/firefox/releases/159.0/win64/en-US/Firefox%20Setup%20159.0.exe"
"$RUNNER_TEMP/setup.exe" /S "/InstallDirectoryPath=C:\retail159"
for i in $(seq 1 60); do [ -f /c/retail159/firefox.exe ] && break; sleep 2; done
echo "RETAIL=C:\retail159\firefox.exe" >> "$GITHUB_ENV"
else
sudo apt-get update -qq && sudo apt-get install -y -qq xvfb >/dev/null
python -m pip install --quiet "playwright==$(cat scripts/playwright_pin.txt)" && sudo "$(which python)" -m playwright install-deps firefox >/dev/null
curl -sSL "https://archive.mozilla.org/pub/firefox/releases/159.0/linux-x86_64/en-US/firefox-159.0.tar.xz" | tar -xJ -C "$RUNNER_TEMP"
echo "RETAIL=$RUNNER_TEMP/firefox/firefox" >> "$GITHUB_ENV"
fi
sha256sum "$RUNNER_TEMP"/setup.exe 2>/dev/null || true
- name: The study
env:
PYTHONUNBUFFERED: "1"
run: |
if [ "$RUNNER_OS" = "Linux" ]; then PRE="xvfb-run -a"; else PRE=""; fi
$PRE python scripts/study_processes.py --retail "$RETAIL" --ours "$OURS" --out evidence --seconds 30 | tee -a "$GITHUB_STEP_SUMMARY"
- name: Close every Firefox left
if: always()
shell: pwsh
run: |
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
- name: Upload the evidence
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: study-processes-${{ matrix.os }}-${{ github.run_id }}
path: evidence
if-no-files-found: warn
retention-days: 30
@@ -0,0 +1,83 @@
# study-processes-medium-hunt.yml - hunt scaffolding, never merged. Runs only on a push to a `hunt/study-processes-medium**` branch.
#
# Run 43355270060 (ProcessModel 109cc93): on the Windows runner, an administrator, our tabs ran at LOW integrity where the retail's
# ran UNTRUSTED, our GPU process MEDIUM where the retail's was LOW, our parent HIGH where the retail's was MEDIUM (its launcher
# process starts the browser again de-elevated). The same study, both browsers started from a Basic User token
# (`runas /trustlevel:0x20000`: the administrators group off, medium integrity), as a user's browser starts: does the difference
# come from the elevation or from our sandbox? Windows only; nothing of the product changes.
name: study processes medium hunt
on:
push:
branches: ['hunt/study-processes-medium**']
permissions:
contents: read
concurrency:
group: study-processes-medium-hunt-${{ github.ref }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ github.token }}
jobs:
study:
name: study medium (windows-2022)
runs-on: windows-2022
timeout-minutes: 30
strategy:
max-parallel: 1
matrix:
os: [windows-2022]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with: { python-version: '3.11' }
- name: Install the wrapper, the published engine, the retail Firefox 159.0
run: |
set -e
python -m pip install --quiet --upgrade pip
python -m pip install --quiet ".[dev]" psutil
echo "OURS=$(cd "$RUNNER_TEMP" && python -m invisible_playwright fetch | tail -1)" >> "$GITHUB_ENV"
curl -sSL -o "$RUNNER_TEMP/setup.exe" "https://archive.mozilla.org/pub/firefox/releases/159.0/win64/en-US/Firefox%20Setup%20159.0.exe"
"$RUNNER_TEMP/setup.exe" /S "/InstallDirectoryPath=C:\retail159"
for i in $(seq 1 60); do [ -f /c/retail159/firefox.exe ] && break; sleep 2; done
echo "RETAIL=C:\retail159\firefox.exe" >> "$GITHUB_ENV"
- name: The study from a Basic User token (medium integrity, no administrators group)
shell: pwsh
run: |
$py = (python -c "import sys; print(sys.executable)").Trim()
$out = Join-Path $env:GITHUB_WORKSPACE "evidence"
New-Item -ItemType Directory -Force $out | Out-Null
$cmd = Join-Path $env:RUNNER_TEMP "study.cmd"
$done = Join-Path $env:RUNNER_TEMP "study.done"
Set-Content -Encoding ascii $cmd @(
"@echo off",
"cd /d `"$env:GITHUB_WORKSPACE`"",
"`"$py`" scripts\study_processes.py --retail `"$env:RETAIL`" --ours `"$env:OURS`" --out `"$out`" --seconds 30 --repeat 3 > `"$out\study.log`" 2>&1",
"echo %ERRORLEVEL% > `"$done`""
)
whoami /groups | Select-String "Mandatory Label"
runas /trustlevel:0x20000 "$cmd"
for ($i = 0; $i -lt 160 -and -not (Test-Path $done); $i++) { Start-Sleep 5 }
if (-not (Test-Path $done)) { Write-Error "the study did not end in 13 minutes"; exit 1 }
Get-Content "$out\study.log" | Tee-Object -Append -FilePath $env:GITHUB_STEP_SUMMARY
exit [int](Get-Content $done).Trim()
- name: Close every Firefox left
if: always()
shell: pwsh
run: |
Get-Process firefox -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
"left: " + @(Get-Process firefox -ErrorAction SilentlyContinue).Count
- name: Upload the evidence
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: study-processes-medium-${{ github.run_id }}
path: evidence
if-no-files-found: warn
retention-days: 30
+11 -3
View File
@@ -109,13 +109,21 @@ def _snapshot(exe):
"""Every process whose executable sits in the folder of `exe` (the retail's launcher process on Windows starts the browser
again and exits, so its own pid has no tree)."""
folder = os.path.normcase(os.path.dirname(os.path.abspath(exe)))
procs = []
for p in psutil.process_iter(["exe"]):
procs, denied = [], 0
for p in psutil.process_iter(["exe", "name", "cmdline"]):
try:
if p.info["exe"] and os.path.normcase(os.path.dirname(p.info["exe"])) == folder:
path = p.info["exe"]
if path and os.path.normcase(os.path.dirname(path)) == folder:
procs.append(p)
elif not path and (p.info["name"] or "").lower() == os.path.basename(exe).lower():
# a token that may not read the image path (a Basic User token): the name, and the folder in the command line
cmd = " ".join(p.info["cmdline"] or [])
if not cmd or os.path.normcase(os.path.dirname(os.path.abspath(exe))) in os.path.normcase(cmd):
procs.append(p)
except psutil.Error:
denied += 1
continue
print(" (processes not readable from this token: %d)" % denied)
out = []
for p in procs:
try: