Overview
src/locales/translationManager.ts line 30 performs await import(\./\.json\) where language comes directly from user-supplied input. An attacker can pass ../../lib/secrets as the language code and potentially load arbitrary modules or files on the server.
Specifications
Features:
- Language codes are validated against a strict allowlist before any dynamic import
- Unsupported language codes fall back to English without performing the import
Tasks:
- Before the dynamic import, validate:
if (!SUPPORTED_LANGUAGES.includes(language)) { language = DEFAULT_LANGUAGE; }
- Ensure
SUPPORTED_LANGUAGES is an exhaustive array of ISO 639-1 codes
- Add a test asserting that a path-traversal string like
../../etc/passwd falls back to English
- Consider using a static import map instead of dynamic imports
Impacted Files:
src/locales/translationManager.ts
src/locales/config.ts
Acceptance Criteria
- Language codes not in
SUPPORTED_LANGUAGES do not trigger a dynamic import
- Path traversal strings are rejected before any file system access
- Fallback to English occurs gracefully for unsupported locales
Overview
src/locales/translationManager.tsline 30 performsawait import(\./\.json\)wherelanguagecomes directly from user-supplied input. An attacker can pass../../lib/secretsas the language code and potentially load arbitrary modules or files on the server.Specifications
Features:
Tasks:
if (!SUPPORTED_LANGUAGES.includes(language)) { language = DEFAULT_LANGUAGE; }SUPPORTED_LANGUAGESis an exhaustive array of ISO 639-1 codes../../etc/passwdfalls back to EnglishImpacted Files:
src/locales/translationManager.tssrc/locales/config.tsAcceptance Criteria
SUPPORTED_LANGUAGESdo not trigger a dynamic import