fix: sanitiser les paramètres shell dans l'API TTS#3261
Open
kwizer15 wants to merge 2 commits intojeedom:developfrom
Open
fix: sanitiser les paramètres shell dans l'API TTS#3261kwizer15 wants to merge 2 commits intojeedom:developfrom
kwizer15 wants to merge 2 commits intojeedom:developfrom
Conversation
57c8c86 to
7a559a9
Compare
Sanitiser les paramètres text, voice, volume et lang injectés dans shell_exec() via escapeshellarg(), floatval() et validation regex. Extraire la construction des commandes shell dans des fonctions testables (tts.func.php) et ajouter les tests unitaires associés.
7a559a9 to
949c8e3
Compare
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
En relisant
core/api/tts.php, j'ai remarqué que les paramètrestext,voice,volumeetlang(issus deinit()) sont injectés directement dans les commandesshell_exec()sans aucun échappement. Un attaquant disposant d'une clé API TTS valide peut exploiter ça pour exécuter des commandes arbitraires sur le serveur.Exemple concret : un appel avec
text=foo" ; rm -rf / ; echo "casse le guillemet de la commande espeak/pico2wave et injecte du code shell.Corrections apportées
$voice: protégé parescapeshellarg()$text: protégé parescapeshellarg()dans les deux commandes (espeak et pico2wave)$filenameet$md5.wav: protégés parescapeshellarg()(chemins de fichiers)$volume: forcé enfloatval()pour garantir une valeur numérique$lang: validé par regex (/^[a-zA-Z]{2}(-[a-zA-Z]{2,3})?$/) avec fallback surfr-FRSuggested changelog entry
core/api/tts.php)Related issues/external references
Fixes #
Types of changes
PR checklist