Skip to content

fix: confine panel images to assets/, restore the config editor read, load locales via require - #47

Merged
Musiker15 merged 2 commits into
mainfrom
fix/locale-require-loader
Nov 5, 2026
Merged

Musiker15 merged 2 commits into
mainfrom
fix/locale-require-loader

Conversation

@Musiker15

Copy link
Copy Markdown
Member

Description

Three fixes, the first two are urgent.

Security: panel image paths could leave assets/. resolvePanelAsset (and before #46 the inline path.resolve(__dirname, '../../assets', file)) accepted any relative path. With panel.logo.file: "../.env" the panel posted the .env, bot token included, to Discord as an attachment. That let anyone with config.edit in the dashboard read a file that is otherwise owner only. Only a plain file name that resolves inside assets/ or assets/default/ is accepted now. Affects every released version.

Regression from #46: the config editor showed no file. GET /config/:file was routed through the locale loader and answered 404 for config.jsonc, snippets.jsonc and .env. It reads the file directly again, as before.

CodeQL js/file-access-to-http (alert 45). Since #46 the bot read its locales with fs.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 through require() 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

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 🌍 Translation / locale update
  • 📖 Documentation only
  • 🔧 Refactor / chore (no functional change)

How Was This Tested?

npm test: 426 passed. New: tests/config-route.test.js (GET returns the file content) and a path test in tests/panel-assets.test.js (../.env, ..\.env, absolute paths, .., ., default/../../.env all resolve to nothing). Counter-checks: with the old route the config test fails, with the path checks removed the asset test fails.

Checklist

  • My code follows the project's conventions
  • No new production dependencies were added
  • User-facing strings go through client.t(...) (no new strings)
  • Any DB schema change uses an inline migration (no schema change)
  • The bot still works without MSK_API_KEY
  • The bot starts cleanly (npm start) and I verified my change on a test server
  • I updated the relevant docs (none affected)
  • I added a CHANGELOG.md entry under [Unreleased]
  • My commit messages are in English and follow Conventional Commits

Comment thread tests/config-route.test.js Fixed
@Musiker15
Musiker15 merged commit e81e87e into main Nov 5, 2026
6 checks passed
@Musiker15
Musiker15 deleted the fix/locale-require-loader branch November 5, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants