Repository navigation
fix: escape counter metadata in the counters list HTML - #736
Ryuga-Hideki-L wants to merge 1 commit into
Conversation
Counter name, author, version, folder name and links from metadata.txt or the remote counter list were inserted into the dashboard HTML as-is, so a counter could inject markup and scripts into the tosu dashboard.
|
@codex review plz |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66e7f2c143
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| ? `${name} v${version}${externalHasSettings}` | ||
| : `${name}${externalHasSettings}` |
There was a problem hiding this comment.
Insert escaped values with replacement callbacks
When metadata contains a dollar immediately before < or > (for example Name: Cash $<3), escaping produces Cash $<3. Passing this as a String.replace replacement string interprets $& as the matched placeholder, so the heading becomes Cash {NAME}lt;3 and the button metadata is also corrupted. The same regression gives a Linux folder named $>overlay a {URL}gt;overlay preview path and {BUTTONS}gt;overlay action target, breaking previews and folder actions that previously worked. Use replacement callbacks for escaped values and subsequent HTML-fragment substitutions so their contents are inserted literally.
Useful? React with 👍 / 👎.
|
As security, this doesn't hold: a counter is already same-origin HTML/JS with access to the local API, so escaping its metadata prevents nothing. Per our overlay rules the folder must be The remaining concern is code readability: the description is misleading about what the change protects, so I'd rather not have it in the tree as-is. If a concrete case shows up down the line (e.g. a Linux overlay actually breaking), reopen and we can revisit. |
Problem
rebuildJSONinpackages/server/utils/counters.tsbuilds the counters list on/,/availableand/api/counters/search/*by inserting counter metadata straight into HTML:name,author,version,folderName,downloadLink, author links and gallery asset URLs. These values come from a counter'smetadata.txt(or its folder name) and fromhttps://tosu.app/api.json. The dashboard then puts the search response in the page withinnerHTML.So a counter whose metadata contains markup can run scripts on the tosu dashboard origin, and from there call
/api/counters/download/*,/api/counters/delete/*, settings endpoints and so on. A harmless"in a name also breaks the attribute it lands in.Reproduction
static/evil/metadata.txt:Open the dashboard. On
masterthe list containsand
alert(1)runs.Solution
Add a small
escapeHTMLhelper incounters.tsand escape every metadata value thatrebuildJSONinserts into text or attributes. The existing localsnameandauthor(the HTML fragments) are renamed tonameBlockandauthorBlockso the escaped values can use the plain names. The page readsn,a,landvback throughelement.attributes.*.value, which returns the decoded text, so download, update, open and delete get the same strings as before.After the fix the same counter renders as
Affected Files
packages/server/utils/counters.tsVerification
buildLocalCounters(throughtsx) against a static folder with themetadata.txtabove, before and after the change. Output is shown above.prettier --checkandeslintpass on the changed file.tsc --noEmit -p packages/serverreports no errors incounters.ts.AI Declaration
The change was written with Anthropic Claude Opus 5.5 (
claude-opus-5-5) and checked against the reproduction above.