fix: hide Windows service console window and validate uploaded usage - #72
Open
tanqyry wants to merge 2 commits into
Open
fix: hide Windows service console window and validate uploaded usage#72tanqyry wants to merge 2 commits into
tanqyry wants to merge 2 commits into
Conversation
The Windows Task Scheduler task pointed /TR directly at the .cmd wrapper, so Task Scheduler launched it via cmd.exe in the interactive session and a console window flashed every five minutes. Route the task through a hidden wscript launcher (.vbs) that runs the wrapper with window style 0 instead.
The server stored client-computed daily aggregates verbatim, so any authenticated client could report arbitrary spend, token counts, and model names. Add server-side sanity validation that rejects non-finite/negative values, implausible per-day token and cost totals, malformed dates, and empty/oversized/control-character model and source names.
Author
|
this shit is incredibly vibecoded so just know 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Two fixes in one branch:
1. Windows service no longer flashes a console window
The Windows Task Scheduler task pointed
/TRdirectly at theservice-sync.cmdwrapper, so Task Scheduler launched it viacmd.exein the interactive session and a blank console window flashed every five minutes.wscriptlauncher (service-sync.vbs) that runs the wrapper with window style0.windowsTaskCreateArgspoints/TRatwscript.exe "<launcher.vbs>"instead of the.cmd.2. Server-side validation for uploaded usage (anti-forgery)
The server previously stored client-computed daily aggregates verbatim, so any authenticated client could report arbitrary spend, token counts, and model names and put itself at the top of the leaderboard.
Added
sanitizeUsageDaysinapps/api/src/usage/validation.ts, wired intowriteStructuredUsage(covers both/usage/ingestand the legacy/usage/sync), which rejects:costUsdcostUsdabove a $100k/day ceilingYYYY-MM-DD)model/sourcenames (and trims surrounding whitespace)A new
InvalidUsageerror (HTTP 400) is declared on both usage endpoints and returned with a descriptive message.Notes / follow-ups
costUsdentirely and computing from a trusted model → per-token price table) and a model allowlist would make the leaderboard impossible to forge; those need a model/price catalog that doesn't exist in the repo yet and are left as follow-ups.