]> gitweb.ps.run Git - ps-cgit/commitdiff
syntax-highlighting.sh: Fix command injection.
authorJason A. Donenfeld <Jason@zx2c4.com>
Sun, 28 Oct 2012 02:03:41 +0000 (20:03 -0600)
committerJason A. Donenfeld <Jason@zx2c4.com>
Sun, 28 Oct 2012 02:05:50 +0000 (20:05 -0600)
By not quoting the argument, an attacker with the ability to add files
to the repository could pass arbitrary arguments to the highlight
command, in particular, the --plug-in argument which can lead to
arbitrary command execution.

This patch adds simple argument quoting.

filters/syntax-highlighting.sh

index 47f626782a579f4c051230db104a4bbda49f1fbd..24f6bb4ab9713e55dfff355e3f9e871b5fa160bf 100755 (executable)
@@ -53,7 +53,7 @@ EXTENSION="${BASENAME##*.}"
 # found (for example) on EPEL 6.
 #
 # This is for version 2
-exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null
+exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null
 
 # This is for version 3
-#exec highlight --force -f -I -O xhtml -S $EXTENSION 2>/dev/null
+#exec highlight --force -f -I -O xhtml -S "$EXTENSION" 2>/dev/null