Skip to main content
InterviewHubPRO
Section Overview
Q48

Question 48 of 50

Part 3: Advanced Text Processing & Production Internals (Senior / Lead)

96%
Bash & Shell Scripting (50 Qs)•Part 3: Advanced Text Processing & Production Internals (Senior / Lead)

Security in Bash: Preventing command injection (`eval` risks) and safe variable quoting rules.

senior LevelSecurity & Auth

In Simple Words:

  • Never use eval with user input: eval "cmd $user_input" allows an attacker to pass ; rm -rf / or $(malicious_command).
  • Always Quote Variables: Use "$VAR" instead of $VAR. Unquoted variables undergo word splitting and globbing, turning a file named *.* or my file.txt into multiple dangerous arguments.
  • Use printf %q: Sanitizes and safely escapes arbitrary strings for reuse in shell commands.