Repository navigation
fix(shell): read a generated image with a quoted path, type or PowerShell - #8749
kovtcharov-amd merged 2 commits into
Conversation
…hell
On Windows the agent could read an image it had just generated only with
an unquoted `cat`, `dir`, `ls` or `wc`. Quoted paths, which any path with
a space needs, and `type`, `certutil -hashfile` and PowerShell reads were
refused as a protected folder, worded as a blocked write. They now get
the same verdict as the same read of a file in an allowed folder.
Writes, deletes, renames and every other file in GAIA's state folder
stay refused.
PowerShell reads of generated images were also refused because every
generated name holds "SDXL-Turbo", which the cmdlet check read as a
cmdlet. Single-quoted strings, which PowerShell never runs, are no
longer searched for cmdlets.
A refused read is no longer described as "Write blocked": the reason now
names what the path is ("inside protected directory ..."). This also
fixes the spreadsheet tool's message for C:\Windows\win.ini (item 2 of
amd#8697). The write tools' wording is unchanged.
Closes amd#8702
|
Verdict: Request changes On Windows the agent can now read an image it generated, with quoted paths, 🔒 SECURITY CONCERN: hiding single-quoted text from the PowerShell read-only check lets some lines that write a file run without asking, where
Real-world evidenceN/A. No evidence bundle was produced, and the changed surface (cmd.exe and PowerShell on Windows) can't run on this Linux runner. The unit tests weren't run in this job either, because the Python dependencies aren't installed. This verdict rests on static review alone. The PR's own manual Windows check ( 🔍 Technical details🔴 Single-quoted literals are hidden from the cmdlet allowlist for every PowerShell line, not just image reads (
So a string-named command invoked by dot-invocation inside a subexpression or a script block, with a cmdlet that isn't on the dangerous list, no longer trips anything. The smallest fix is to treat dot-invocation of a quoted name as uninspectable wherever it appears: (at 🟢 Write refusals reached through "No approval can grant it" lose their advice (
Checked and fine
Strengths
|
Hiding single-quoted text from the PowerShell cmdlet check let a line
that dot-calls a string-named command inside ( ) or { } run unasked
where main asked. Dot-invocation of a quoted or bracketed name, and a
method named by a quoted string, now count as code the allowlist cannot
inspect, wherever they sit in the line.
On Windows the agent couldn't look at an image it had just generated from the shell unless the path was unquoted and the command was
cat,dir,lsorwc. Paths with spaces need quotes, so the forms a model actually uses (dir "…png",type, PowerShellGet-Item '…') were refused, and the refusal said "Write blocked" for what was a read. Those reads now get the same answer they would get for a file in an allowed folder. Writes, deletes and every other file in GAIA's state folder stay refused, and a refused read now says why without calling it a write.Closes #8702
This also fixes item 2 of #8697: the spreadsheet tool's refusal for
C:\Windows\win.inisaid "Write blocked". It came from the same place, so it now reads "No approval can grant it: 'C:\Windows\win.ini' is inside protected directory 'C:\windows'."Test plan
python -m pytest tests/unit/test_generated_images_readable.py: the new cases fail onmainand pass here. Covered: quoted and unquotedcat/ls/wc/file/dir/more,type,certutil -hashfile, and PowerShellGet-Item/Get-FileHash/Get-Content/Test-Path, each compared with the same line on a file in an allowed folder. Writes, deletes, renames, redirects, PowerShellRemove-Item/Set-Content/Copy-Item, piped or chained PowerShell, and quoted reads of other state files all stay refused. No read refusal contains "Write blocked", and the write refusal still does.& 'Remove-Item','…' | iex,[scriptblock]::Create,. 'x.ps1') get the same verdict as onmainpython util/lint.py --black --isortdir "<path>"and its hash with PowerShellGet-FileHash '<path>'🔍 Technical details
_line_is_read_only) rejects any cmd.exe line with a quote, every PowerShell line, andtype. A newwindows_readsmode, used only for this allowance, also accepts:\");type <file>andcertutil -hashfile <file> [alg];(…).Propertybut never a method call.typeandcertutilstill ask or refuse as they do for any folder; this only stops the path itself from being the reason.'inside a double-quoted string opens nothing, and a body with a backtick, non-ASCII quotes or an unclosed quote is checked whole, as before.is_write_blockednow builds its message from a neutral reason plus write-only advice._unaskable_reason, behind every "No approval can grant it", uses only the reason. The text ofis_write_blockedis unchanged.gaia_fileson the next RC.