Repository navigation
Give this work a before-and-after number, and find out the hardening already worked - #10996
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…already worked Six hardening passes shipped with no measurement (#7822, #8586, #6326, #10540, #10560, #10504). There was no baseline to measure against. There is one now: install.ps1 at commit 1ad4467 is the revision reported in #10805, it hashes to ec29980b..., and VirusTotal holds its verdict. ## The result, run live against the real key | | baseline (1ad4467) | main (2c70592a) | | engines flagging | 1 / 60 | 1 / 61 | | which | Skyhigh BehavesLike.PS.Suspicious.gr | the same | | Sigma | 17 (high 1, medium 11, low 5) | 14 (medium 10, low 4) | | YARA | 2 | 0 | The **high**-severity Sigma rule is gone. So are both crowdsourced YARA hits, `INDICATOR_SUSPICIOUS_PWSH_B64Encoded_Concatenated_FileEXEC` and `Windows_API_Function`. Three fewer Sigma rules overall. The Skyhigh verdict has not moved, and that is reported as unchanged rather than dressed up: a cloud behavioural verdict is not recomputed because we deleted some code. So the static indicators, which are what drives the alarming scores third-party analysis sites report, already improved measurably. That was not knowable before. Two corrections to what I wrote in the plan, both from running this rather than reasoning about it: - I recorded current main's install.ps1 as **not on VirusTotal**. It is. It has been scanned since, so the delta above is real and not a projection. - I treated the prior passes as unverifiable. They are verifiable, retroactively, and they worked on the axis they could affect. ## Three axes, separately Reporting only the engine count makes every shape win look like it achieved nothing. Reporting only Sigma overclaims. Both, or the number is not worth having. Engines are compared **by name**, not by count. A count-only comparison calls the single most consequential possible change -- Skyhigh's detection being replaced by Microsoft's, one engine before and one after -- "no difference". Defender is on every Windows machine; Skyhigh is enterprise-deployed. There is a test for exactly that case. Sigma is compared **per severity**, not in total. Trading one high for three lows is an improvement a total calls a regression, and the reverse is a regression a total calls an improvement. ## GET only, and VOID is not clean There is no upload path, and that is a deliberate omission rather than an oversight. A freshly uploaded file is a prevalence-zero, first-seen sample, which is exactly what `CloudBlockLevel HighPlus` and ASR rule `01443614` punish -- so uploading a candidate can *create* the detection it was meant to measure, under a hash no user will ever have. Released artefacts are uploaded by `virustotal_scan.py` at release time; branches are not. A test parses the module and asserts no non-GET method appears, having first been written as a grep and caught matching the module's own explanation of why there is no upload. So an unknown hash is VOID, exit 3, never clean. Also VOID: a missing `VT_API_KEY`, and a file VirusTotal knows but has never analysed -- that last one being the subtle case, because zero engine verdicts is not sixty engines clearing the file. Exit codes are distinct: 3 could-not-measure, 2 worse, 0 not worse. ## The baseline is checked, not trusted A baseline hash copied out of an issue is a number nobody can verify, and if it ever pointed at the wrong file every delta reported against it would be wrong while the lane looked perfectly healthy. So both a test and a workflow step recompute it from this repository's history -- `git show 1ad4467:install.ps1` -- and assert the 427,113 bytes the sample is recorded as. A shallow clone skips rather than fails. ## Verification - 613 passed, 6 skipped across `tests/security/`, including 25 new tests. - Run live against the real key; the table above is its actual output. - Weighted toward the failure direction: a new high-severity rule, a new YARA hit, an engine swap at an unchanged count, and a medium promoted to high must each be reported as worse. One test replaces the comparison with one that reports nothing and requires the self-test to notice, because a control that cannot fail is decoration. - Both parsers are fuzzed against schema drift. VirusTotal has renamed and added buckets over time, and a crash would break the measurement on precisely the day the schema moved.
7707419 to
be05afb
Compare
…a claim elsewhere scripts/virustotal_delta.py (#10996) produced the first before-and-after this work has had, so it belongs beside the detections it qualifies: Sigma 17 -> 14 with the high-severity rule gone, both crowdsourced YARA hits gone including Windows_API_Function, and the Skyhigh verdict unchanged. The last part is recorded as plainly as the first. The honest expectation is that the static axis moves first and the engine axis may never move, and a document that only listed the wins would mislead the next person reading it to decide what to work on.
…can measure something `secrets.VT_API_KEY` does not exist. `VT_API_KEY` is the ENV VAR name the Python reads (`scripts/virustotal_scan.py:37`); the repository secret is `VIRUS_TOTAL_API_TOKEN`, which is the only VirusTotal secret in all 51 workflows, and `release-desktop.yml:2193` maps it the same way. As written the expression expanded to empty and the lane exited 3 / VOID on every dispatch. That is the right failure shape -- it refuses to report a clean it did not measure -- but a lane that can never measure anything is not worth having, and the failure only surfaces after someone dispatches it and waits. Two guards added, because both halves of this were invisible: - `test_the_workflow_reads_the_secret_this_repository_actually_has` pins the secret name in both directions and also asserts the checkout keeps `fetch-depth: 0`, since the step that reverifies the baseline against commit 1ad4467 reverifies nothing on a shallow clone. - `test_the_baseline_hash_is_the_file_the_reporter_ran` now checks the constant's shape unconditionally before the git half. That git half skips on a shallow clone, which is every CI lane that collects `tests/security` -- so the one assertion tying the baseline to real history was green locally and silently absent everywhere it mattered.
Fixed: the lane read a secret that does not exist
As written the expression expanded to empty and the lane exited 3 / Two guards added, because both halves of this were invisible:
Also confirmed independently: both this tool and |
The per-severity comparison reported each bucket independently, which cannot express a trade: swapping the single high rule for three extra low ones moves two buckets in opposite directions, so it landed in worse and in better at once and exit_code answered worse. The comment beside that loop calls exactly that swap an improvement. SEVERITIES is ordered most severe first, so the most severe bucket that moved now decides and the rest are reported alongside it without flipping the verdict. The zero-engine guard was on the candidate only. A baseline hash VirusTotal knows but has never analysed carries no engines, no Sigma and no YARA, so every finding on the candidate read as newly introduced and the run exited 2 having compared against nothing.
|
@codex security review |
Neither lookup carried a deadline, and request can spend four 300-second socket attempts plus 20, 40 and 80 seconds of backoff. The workflow gives the whole job 20 minutes, so the baseline lookup alone could exhaust it and the runner would kill the step before it fetched the candidate or wrote its summary, which is a lost run rather than a reported one. Both lookups now share a 420 second budget and an expired budget is reported as VOID, since we did not find out. YARA hits were keyed on the rule name alone, so the same rule identifier appearing in two crowdsourced rulesets collapsed to one entry: a candidate could gain a hit from a second ruleset, parse to the same list as the baseline, and exit 0 on a real regression. Keyed on ruleset and rule now. Engine names and detection labels are third-party text and the report is appended to GITHUB_STEP_SUMMARY, where a newline ends the row, a pipe opens a cell and an angle bracket starts HTML that GitHub renders. virustotal_scan._md_text exists for exactly this and the report was bypassing it; reused rather than duplicated.
A dispatch can supply baseline_sha256, and the lookup and the comparison then use that hash while the header still announced the recorded identity and printed install.ps1's historical scores beside the override's live table. That is an artifact built to be misattributed: the numbers belong to one file and the name to another. The note is now printed only when the baseline hash really is the recorded one, and an override says so and disclaims the historical comparison.
VirusTotalClient.request signals an expired deadline with TimeoutError, which inherits from OSError rather than RuntimeError, so the handler in fetch never ran and the workflow died with a traceback before render wrote its summary. That is the lost run the deadline was meant to prevent. Catch both and keep returning a VOID row.
The parser warned in its own docstring that VirusTotal renames and adds severity buckets, then read a fixed key list, so a candidate that gained rules only in a new bucket produced a dictionary identical to the baseline's and the run exited 0 on a regression. Keep every reported bucket. Unrankable ones stay out of the ordered trade-off, which depends on knowing which of two buckets is more severe, and a rise in one is reported as worse rather than assumed minor.
parse_stats names type-unsupported and failure as categories VirusTotal has added, but ScanStats has fields only for five buckets, so the engine count this report prints was short by however many engines answered that way, and a response made up entirely of those buckets summed to zero and voided the run as unanalysed. Sum every numeric bucket from the raw stats, which leaves the shared dataclass alone for the release scanner.
An engine that flagged the baseline and is absent from the candidate's results has not cleared it, it did not evaluate it, and a set difference cannot tell those apart. Since Skyhigh is the one engine that actually flags this file, a sparse candidate analysis could print the single most consequential sentence in the report and exit 0. Track which engines returned a verdict of any kind, call only an answering non-flagging engine cleared, and report the silent ones as an unanswered question.
The responder set was built on the truthiness of the category, so timeout, confirmed-timeout, failure and type-unsupported counted as answers while parse_detections correctly left them out of the flagging list. An engine returning one of those appeared in neither set and was reported as having stopped flagging the candidate, which is the same mistake as treating absence as a clean verdict.
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…already worked (unslothai#10996) * Give this work a before-and-after number, and find out the hardening already worked Six hardening passes shipped with no measurement (unslothai#7822, unslothai#8586, unslothai#6326, unslothai#10540, unslothai#10560, unslothai#10504). There was no baseline to measure against. There is one now: install.ps1 at commit 1ad4467 is the revision reported in unslothai#10805, it hashes to ec29980b..., and VirusTotal holds its verdict. ## The result, run live against the real key | | baseline (1ad4467) | main (2c70592a) | | engines flagging | 1 / 60 | 1 / 61 | | which | Skyhigh BehavesLike.PS.Suspicious.gr | the same | | Sigma | 17 (high 1, medium 11, low 5) | 14 (medium 10, low 4) | | YARA | 2 | 0 | The **high**-severity Sigma rule is gone. So are both crowdsourced YARA hits, `INDICATOR_SUSPICIOUS_PWSH_B64Encoded_Concatenated_FileEXEC` and `Windows_API_Function`. Three fewer Sigma rules overall. The Skyhigh verdict has not moved, and that is reported as unchanged rather than dressed up: a cloud behavioural verdict is not recomputed because we deleted some code. So the static indicators, which are what drives the alarming scores third-party analysis sites report, already improved measurably. That was not knowable before. Two corrections to what I wrote in the plan, both from running this rather than reasoning about it: - I recorded current main's install.ps1 as **not on VirusTotal**. It is. It has been scanned since, so the delta above is real and not a projection. - I treated the prior passes as unverifiable. They are verifiable, retroactively, and they worked on the axis they could affect. ## Three axes, separately Reporting only the engine count makes every shape win look like it achieved nothing. Reporting only Sigma overclaims. Both, or the number is not worth having. Engines are compared **by name**, not by count. A count-only comparison calls the single most consequential possible change -- Skyhigh's detection being replaced by Microsoft's, one engine before and one after -- "no difference". Defender is on every Windows machine; Skyhigh is enterprise-deployed. There is a test for exactly that case. Sigma is compared **per severity**, not in total. Trading one high for three lows is an improvement a total calls a regression, and the reverse is a regression a total calls an improvement. ## GET only, and VOID is not clean There is no upload path, and that is a deliberate omission rather than an oversight. A freshly uploaded file is a prevalence-zero, first-seen sample, which is exactly what `CloudBlockLevel HighPlus` and ASR rule `01443614` punish -- so uploading a candidate can *create* the detection it was meant to measure, under a hash no user will ever have. Released artefacts are uploaded by `virustotal_scan.py` at release time; branches are not. A test parses the module and asserts no non-GET method appears, having first been written as a grep and caught matching the module's own explanation of why there is no upload. So an unknown hash is VOID, exit 3, never clean. Also VOID: a missing `VT_API_KEY`, and a file VirusTotal knows but has never analysed -- that last one being the subtle case, because zero engine verdicts is not sixty engines clearing the file. Exit codes are distinct: 3 could-not-measure, 2 worse, 0 not worse. ## The baseline is checked, not trusted A baseline hash copied out of an issue is a number nobody can verify, and if it ever pointed at the wrong file every delta reported against it would be wrong while the lane looked perfectly healthy. So both a test and a workflow step recompute it from this repository's history -- `git show 1ad4467:install.ps1` -- and assert the 427,113 bytes the sample is recorded as. A shallow clone skips rather than fails. ## Verification - 613 passed, 6 skipped across `tests/security/`, including 25 new tests. - Run live against the real key; the table above is its actual output. - Weighted toward the failure direction: a new high-severity rule, a new YARA hit, an engine swap at an unchanged count, and a medium promoted to high must each be reported as worse. One test replaces the comparison with one that reports nothing and requires the self-test to notice, because a control that cannot fail is decoration. - Both parsers are fuzzed against schema drift. VirusTotal has renamed and added buckets over time, and a crash would break the measurement on precisely the day the schema moved. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Read the VirusTotal secret this repository actually has, so the lane can measure something `secrets.VT_API_KEY` does not exist. `VT_API_KEY` is the ENV VAR name the Python reads (`scripts/virustotal_scan.py:37`); the repository secret is `VIRUS_TOTAL_API_TOKEN`, which is the only VirusTotal secret in all 51 workflows, and `release-desktop.yml:2193` maps it the same way. As written the expression expanded to empty and the lane exited 3 / VOID on every dispatch. That is the right failure shape -- it refuses to report a clean it did not measure -- but a lane that can never measure anything is not worth having, and the failure only surfaces after someone dispatches it and waits. Two guards added, because both halves of this were invisible: - `test_the_workflow_reads_the_secret_this_repository_actually_has` pins the secret name in both directions and also asserts the checkout keeps `fetch-depth: 0`, since the step that reverifies the baseline against commit 1ad4467 reverifies nothing on a shallow clone. - `test_the_baseline_hash_is_the_file_the_reporter_ran` now checks the constant's shape unconditionally before the git half. That git half skips on a shallow clone, which is every CI lane that collects `tests/security` -- so the one assertion tying the baseline to real history was green locally and silently absent everywhere it mattered. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Compare Sigma severities in order, and void an unanalysed baseline too The per-severity comparison reported each bucket independently, which cannot express a trade: swapping the single high rule for three extra low ones moves two buckets in opposite directions, so it landed in worse and in better at once and exit_code answered worse. The comment beside that loop calls exactly that swap an improvement. SEVERITIES is ordered most severe first, so the most severe bucket that moved now decides and the rest are reported alongside it without flipping the verdict. The zero-engine guard was on the candidate only. A baseline hash VirusTotal knows but has never analysed carries no engines, no Sigma and no YARA, so every finding on the candidate read as newly introduced and the run exited 2 having compared against nothing. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Bound the lookups, keep ruleset identity, and escape third-party text Neither lookup carried a deadline, and request can spend four 300-second socket attempts plus 20, 40 and 80 seconds of backoff. The workflow gives the whole job 20 minutes, so the baseline lookup alone could exhaust it and the runner would kill the step before it fetched the candidate or wrote its summary, which is a lost run rather than a reported one. Both lookups now share a 420 second budget and an expired budget is reported as VOID, since we did not find out. YARA hits were keyed on the rule name alone, so the same rule identifier appearing in two crowdsourced rulesets collapsed to one entry: a candidate could gain a hit from a second ruleset, parse to the same list as the baseline, and exit 0 on a real regression. Keyed on ruleset and rule now. Engine names and detection labels are third-party text and the report is appended to GITHUB_STEP_SUMMARY, where a newline ends the row, a pipe opens a cell and an angle bracket starts HTML that GitHub renders. virustotal_scan._md_text exists for exactly this and the report was bypassing it; reused rather than duplicated. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Stop labelling an overridden baseline as the recorded install.ps1 A dispatch can supply baseline_sha256, and the lookup and the comparison then use that hash while the header still announced the recorded identity and printed install.ps1's historical scores beside the override's live table. That is an artifact built to be misattributed: the numbers belong to one file and the name to another. The note is now printed only when the baseline hash really is the recorded one, and an override says so and disclaims the historical comparison. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Catch a spent deadline in the VirusTotal delta lookup VirusTotalClient.request signals an expired deadline with TimeoutError, which inherits from OSError rather than RuntimeError, so the handler in fetch never ran and the workflow died with a traceback before render wrote its summary. That is the lost run the deadline was meant to prevent. Catch both and keep returning a VOID row. * Keep Sigma buckets this tool cannot rank The parser warned in its own docstring that VirusTotal renames and adds severity buckets, then read a fixed key list, so a candidate that gained rules only in a new bucket produced a dictionary identical to the baseline's and the run exited 0 on a regression. Keep every reported bucket. Unrankable ones stay out of the ordered trade-off, which depends on knowing which of two buckets is more severe, and a rise in one is reported as worse rather than assumed minor. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Count every engine verdict bucket, not the five the dataclass carries parse_stats names type-unsupported and failure as categories VirusTotal has added, but ScanStats has fields only for five buckets, so the engine count this report prints was short by however many engines answered that way, and a response made up entirely of those buckets summed to zero and voided the run as unanalysed. Sum every numeric bucket from the raw stats, which leaves the shared dataclass alone for the release scanner. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Require an explicit verdict before calling an engine cleared An engine that flagged the baseline and is absent from the candidate's results has not cleared it, it did not evaluate it, and a set difference cannot tell those apart. Since Skyhigh is the one engine that actually flags this file, a sparse candidate analysis could print the single most consequential sentence in the report and exit 0. Track which engines returned a verdict of any kind, call only an answering non-flagging engine cleared, and report the silent ones as an unanswered question. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Only a conclusive verdict clears a prior detection The responder set was built on the truthiness of the category, so timeout, confirmed-timeout, failure and type-unsupported counted as answers while parse_detections correctly left them out of the flagging list. An engine returning one of those appeared in neither set and was reported as having stopped flagging the candidate, which is the same mistake as treating absence as a clean verdict. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Six hardening passes shipped with no measurement (#7822, #8586, #6326, #10540, #10560, #10504). There was no baseline to measure against. There is one now:
install.ps1at commit1ad44677dis the revision reported in #10805, it hashes toec29980b..., and VirusTotal holds its verdict.The result, run live against the real key
1ad44677d)2c70592a)BehavesLike.PS.Suspicious.grThe high-severity Sigma rule is gone. So are both crowdsourced YARA hits,
INDICATOR_SUSPICIOUS_PWSH_B64Encoded_Concatenated_FileEXECandWindows_API_Function. Three fewer Sigma rules overall. The Skyhigh verdict has not moved, and that is reported as unchanged rather than dressed up: a cloud behavioural verdict is not recomputed because we deleted some code.So the static indicators, which are what drives the alarming scores third-party analysis sites report, already improved measurably. That was not knowable before.
Two corrections to what I wrote in the plan, both from running this rather than reasoning about it:
main'sinstall.ps1as not on VirusTotal. It is. It has been scanned since, so the delta above is real and not a projection.Three axes, separately
Reporting only the engine count makes every shape win look like it achieved nothing. Reporting only Sigma overclaims. Both, or the number is not worth having.
Engines are compared by name, not by count. A count-only comparison calls the single most consequential possible change -- Skyhigh's detection being replaced by Microsoft's, one engine before and one after -- "no difference". Defender is on every Windows machine; Skyhigh is enterprise-deployed. There is a test for exactly that case.
Sigma is compared per severity, not in total. Trading one high for three lows is an improvement a total calls a regression, and the reverse is a regression a total calls an improvement.
GET only, and VOID is not clean
There is no upload path, and that is a deliberate omission rather than an oversight. A freshly uploaded file is a prevalence-zero, first-seen sample, which is exactly what
CloudBlockLevel HighPlusand ASR rule01443614punish, so uploading a candidate can create the detection it was meant to measure, under a hash no user will ever have. Released artefacts are uploaded byvirustotal_scan.pyat release time; branches are not.A test parses the module and asserts no non-GET method appears. It was first written as a grep and caught matching the module's own explanation of why there is no upload, which is a good argument for parsing.
So an unknown hash is VOID, exit 3, never clean. Also VOID: a missing
VT_API_KEY, and a file VirusTotal knows but has never analysed. That last one is the subtle case, because zero engine verdicts is not sixty engines clearing the file. Exit codes are distinct: 3 could-not-measure, 2 worse, 0 not worse.The baseline is checked, not trusted
A baseline hash copied out of an issue is a number nobody can verify, and if it ever pointed at the wrong file every delta reported against it would be wrong while the lane looked perfectly healthy. So both a test and a workflow step recompute it from this repository's history (
git show 1ad44677d:install.ps1) and assert the 427,113 bytes the sample is recorded as. A shallow clone skips rather than fails.Verification
tests/security/, including 25 new tests.Once #10990 lands, this measured result belongs in
docs/windows-installer-av-shapes.mdbeside the detections it corrects.