]> Kevux Git Server - fll/commitdiff
Security: Explicitly define IFS to prevent misuse.
authorKevin Day <Kevin@kevux.org>
Fri, 6 Jun 2025 02:35:34 +0000 (21:35 -0500)
committerKevin Day <Kevin@kevux.org>
Fri, 6 Jun 2025 02:35:34 +0000 (21:35 -0500)
The scripts are written with certain expectations.
This expectation may not be properly met if the `IFS` value is changed.
This can potentially be used to create some sort of exploit.

Explicitly define IFS and then do so at a local variable scope to prevent affecting the callers IFS setting.`

16 files changed:
build/scripts/bootstrap-example.sh
build/scripts/bootstrap.sh
build/scripts/generate_codepoints_from_digits.sh
build/scripts/generate_ctags.sh
build/scripts/generate_unicode.sh
build/scripts/install.sh
build/scripts/package.sh
build/scripts/test.sh
level_3/fake/data/build/process_post.sh
level_3/fake/data/build/process_pre.sh
level_3/fake/data/projects/go/example_go/data/build/process_post.sh
level_3/fake/data/projects/go/example_go/data/build/process_pre.sh
level_3/fss_read/tests/runtime/script/generate.sh
level_3/fss_read/tests/runtime/script/verify.sh
level_3/iki_read/tests/runtime/script/generate.sh
level_3/iki_read/tests/runtime/script/verify.sh

index d704449..c049419 100644 (file)
@@ -42,6 +42,8 @@
 #
 
 main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
   if [[ ${SHELL_ENGINE} == "zsh" ]] ; then
     emulate ksh
   fi
index aef0497..1e5562c 100644 (file)
@@ -13,6 +13,7 @@
 #
 
 bootstrap_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
 
   if [[ ${SHELL_ENGINE} == "zsh" ]] ; then
     emulate ksh
@@ -3035,4 +3036,4 @@ bootstrap_cleanup() {
   unset bootstrap_cleanup
 }
 
-bootstrap_main $*
+bootstrap_main ${*}
index 1bc3410..fe7d3a4 100644 (file)
@@ -9,6 +9,8 @@
 #
 
 main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
   local -i first="$1"
   local -i last="$2"
 
index a3d86b6..23467c9 100644 (file)
@@ -10,6 +10,7 @@
 #
 
 main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
 
   if [[ ${SHELL_ENGINE} == "zsh" ]] ; then
     emulate ksh
@@ -290,4 +291,4 @@ generate_ctags_cleanup() {
   unset generate_ctags_cleanup
 }
 
-main $*
+main ${*}
index 9815ff1..b339669 100644 (file)
@@ -11,6 +11,8 @@
 #
 
 main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
   local file_input="codes.txt"
   local mode=$1
   local code=
index c8972d1..fb971b5 100644 (file)
@@ -14,6 +14,7 @@
 #
 
 install_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
 
   if [[ ${SHELL_ENGINE} == "zsh" ]] ; then
     emulate ksh
@@ -877,4 +878,4 @@ install_cleanup() {
   unset install_cleanup
 }
 
-install_main $*
+install_main ${*}
index a87472d..fe89988 100644 (file)
@@ -12,6 +12,7 @@
 #
 
 package_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
 
   if [[ ${SHELL_ENGINE} == "zsh" ]] ; then
     emulate ksh
@@ -2438,4 +2439,4 @@ package_cleanup() {
   unset package_cleanup
 }
 
-package_main $*
+package_main ${*}
index e835939..51ddbb0 100644 (file)
@@ -14,6 +14,7 @@
 #
 
 test_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
   local shell_command=bash
 
   if [[ ${SHELL_ENGINE} == "zsh" ]] ; then
@@ -1129,4 +1130,4 @@ test_cleanup() {
   unset test_cleanup
 }
 
-test_main $*
+test_main ${*}
index 500d1d0..c00efa9 100755 (executable)
@@ -8,6 +8,8 @@
 # The dependencies of this script are: bash and sed.
 #
 process_post_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
   local grab_next=
   local do_color=dark
   local i=0
index a7500c0..1f4c785 100755 (executable)
@@ -8,6 +8,8 @@
 # The dependencies of this script are: bash and sed.
 #
 process_pre_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
   local grab_next=
   local do_color=dark
   local i=0
index 05a7907..a5fc4d8 100755 (executable)
@@ -1,2 +1,8 @@
 #!/bin/bash
 
+main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
+}
+
+main ${*}
index 05a7907..a5fc4d8 100755 (executable)
@@ -1,2 +1,8 @@
 #!/bin/bash
 
+main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
+}
+
+main ${*}
index 11c8479..d3543bb 100644 (file)
@@ -11,6 +11,8 @@
 #
 
 generate_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
   local file_source="${2}"
   local path_destination="${3}"
   local failure=0
index 64b9517..b6eb78c 100644 (file)
@@ -10,6 +10,8 @@
 #
 
 verify_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
   local path_build="${1}"
   local path_expect="${2}"
   local test_name="${3}"
index 7138fbe..40dcc5d 100644 (file)
@@ -11,6 +11,8 @@
 #
 
 generate_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
   local file_source="${2}"
   local path_destination="${3}"
   local failure=0
index 64b9517..b6eb78c 100644 (file)
@@ -10,6 +10,8 @@
 #
 
 verify_main() {
+  local IFS=$' \t\n' # Prevent IFS exploits by overriding with a local scope.
+
   local path_build="${1}"
   local path_expect="${2}"
   local test_name="${3}"