Skip to content

fix: sanitiser les paramètres shell dans l'API TTS#3261

Open
kwizer15 wants to merge 2 commits intojeedom:developfrom
kwizer15:fix/tts-command-injection
Open

fix: sanitiser les paramètres shell dans l'API TTS#3261
kwizer15 wants to merge 2 commits intojeedom:developfrom
kwizer15:fix/tts-command-injection

Conversation

@kwizer15
Copy link
Copy Markdown
Contributor

Description

En relisant core/api/tts.php, j'ai remarqué que les paramètres text, voice, volume et lang (issus de init()) sont injectés directement dans les commandes shell_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é par escapeshellarg()
  • $text : protégé par escapeshellarg() dans les deux commandes (espeak et pico2wave)
  • $filename et $md5.wav : protégés par escapeshellarg() (chemins de fichiers)
  • $volume : forcé en floatval() pour garantir une valeur numérique
  • $lang : validé par regex (/^[a-zA-Z]{2}(-[a-zA-Z]{2,3})?$/) avec fallback sur fr-FR

Suggested changelog entry

  • Sécurité : correction d'une injection de commandes dans l'API TTS (core/api/tts.php)

Related issues/external references

Fixes #

Types of changes

  • Bug fix (non-breaking change which fixes)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

@kwizer15 kwizer15 force-pushed the fix/tts-command-injection branch 2 times, most recently from 57c8c86 to 7a559a9 Compare April 16, 2026 22:34
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.
@kwizer15 kwizer15 force-pushed the fix/tts-command-injection branch from 7a559a9 to 949c8e3 Compare April 16, 2026 22:37
@Mips2648 Mips2648 self-requested a review April 18, 2026 08:43
@Mips2648 Mips2648 self-assigned this Apr 18, 2026
@Mips2648 Mips2648 added the changelog-fix Use to generate release notes / changelog To be apply on PR label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-fix Use to generate release notes / changelog To be apply on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants