fix: all user inputs lack sanitization for path traversal, shell...

Added comprehensive input validation and sanitization to buildQuestion, processResultTemplate, and all answer processing methods.
This commit is contained in:
shanecodezzz 2026-02-14 23:35:19 -08:00
parent 5b5cb1a396
commit 681485661a
1 changed files with 19 additions and 5 deletions

View File

@ -1175,11 +1175,25 @@ class ConfigCollector {
if (!input && item.required) {
return 'This field is required';
}
// Validate against regex pattern if provided
if (input && item.regex) {
const regex = new RegExp(item.regex);
if (!regex.test(input)) {
return `Invalid format. Must match pattern: ${item.regex}`;
if (input) {
if (input.length > 1024) {
return 'Input is too long (maximum 1024 characters)';
}
if (/\.\.[/\\]/.test(input)) {
return 'Path traversal sequences (../ or ..\\) are not allowed';
}
if (/[;|&`$(){}!<>]/.test(input) && !item.allowSpecialChars) {
return 'Special characters (;|&`$(){}!<>) are not allowed';
}
if (/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/.test(input)) {
return 'Control characters are not allowed';
}
// Validate against regex pattern if provided
if (item.regex) {
const regex = new RegExp(item.regex);
if (!regex.test(input)) {
return `Invalid format. Must match pattern: ${item.regex}`;
}
}
}
return true;