Repository navigation
fix: confine panel images to assets/, restore the config editor read, load locales via require - #47
Merged
Merged
Conversation
… load locales via require
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.
Description
Three fixes, the first two are urgent.
Security: panel image paths could leave
assets/.resolvePanelAsset(and before #46 the inlinepath.resolve(__dirname, '../../assets', file)) accepted any relative path. Withpanel.logo.file: "../.env"the panel posted the.env, bot token included, to Discord as an attachment. That let anyone withconfig.editin the dashboard read a file that is otherwise owner only. Only a plain file name that resolves insideassets/orassets/default/is accepted now. Affects every released version.Regression from #46: the config editor showed no file.
GET /config/:filewas routed through the locale loader and answered 404 forconfig.jsonc,snippets.jsoncand.env. It reads the file directly again, as before.CodeQL
js/file-access-to-http(alert 45). Since #46 the bot read its locales withfs.readFileSync; those texts end up in the transcript, which is uploaded to the MSK API, so CodeQL saw file data flowing into an outbound request. The bot now loads locales throughrequire()again, as it did before #46 (with the cache entry dropped first, so dashboard edits still apply on the next load). The dashboard editor keeps reading the raw files; it sends nothing out.Related Issue
None.
Type of Change
How Was This Tested?
npm test: 426 passed. New:tests/config-route.test.js(GET returns the file content) and a path test intests/panel-assets.test.js(../.env,..\.env, absolute paths,..,.,default/../../.envall resolve to nothing). Counter-checks: with the old route the config test fails, with the path checks removed the asset test fails.Checklist
client.t(...)(no new strings)MSK_API_KEYnpm start) and I verified my change on a test serverCHANGELOG.mdentry under[Unreleased]