You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Running a Telegram Bot means it is connected to the public and you never know what's send to your Bot.</p>
342
343
<p>Bash scripts in general are not designed to be bulletproof, so consider this Bot as a proof of concept. Bash programmers often struggle with 'quoting hell' and globbing, see <ahref="https://unix.stackexchange.com/questions/171346/security-implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells">Implications of wrong quoting</a>.</p>
343
344
<p>Whenever you are processing input from untrusted sources (messages, files, network) you must be as careful as possible (e.g. set IFS appropriately, disable globbing with <code>set -f</code> and quote everything). In addition remove unused scripts and examples from your Bot (e.g. everything in <code>example/</code>) and disable/remove all unused bot commands.</p>
344
-
<p>It's important to escape or remove <code>$</code> in input from user, files or network (<em>as bashbot does</em>). One of the powerful features of Unix shells is variable and command substitution using <code>${}</code> and <code>$()</code> can lead to remote code execution (RCE) or remote information disclosure (RID) bugs if unescaped <code>$</code> is included in untrusted input (e.g. <code>$$</code> or <code>$(rm -rf /*)</code>).</p>
345
+
<p>It's important to escape or remove <code>$</code>and ` in input from user, files or network (<em>as bashbot does</em>). One of the powerful features of Unix shells is variable and command substitution using <code>${var}</code>, <code>$(cmd)</code>and `cmd` can lead to remote code execution (RCE) or remote information disclosure (RID) bugs if unescaped <code>$</code> or ` is included in untrusted input (e.g. <code>$$</code> or <code>$(rm -rf /*)</code>).</p>
345
346
<p>A powerful tool to improve your scripts is <code>shellcheck</code>. You can <ahref="https://www.shellcheck.net/">use it online</a> or <ahref="https://github.com/koalaman/shellcheck#installing">install shellcheck locally</a>. Shellcheck is used extensively in bashbot development to ensure a high code quality (e.g. it's not allowed to push changes without passing all shellcheck tests). In addition bashbot has a <ahref="doc/7_develop.md">test suite</a> to check if important functionality is working as expected.</p>
346
347
<h3>Use printf whenever possible</h3>
347
348
<p>If you're writing a script that accepts external input (e.g. from the user as arguments or the file system), you shouldn't use echo to display it. <ahref="https://unix.stackexchange.com/a/6581">Use printf whenever possible</a>.</p>
@@ -392,6 +393,6 @@ <h3>Blocked by telegram?</h3>
392
393
<p>@Gnadelwartz</p>
393
394
<h2>That's it all guys!</h2>
394
395
<p>If you feel that there's something missing or if you found a bug, feel free to submit a pull request!</p>
Copy file name to clipboardExpand all lines: README.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,8 +146,9 @@ Whenever you are processing input from untrusted sources (messages, files, netwo
146
146
(e.g. set IFS appropriately, disable globbing with `set -f` and quote everything). In addition remove unused scripts and examples
147
147
from your Bot (e.g. everything in `example/`) and disable/remove all unused bot commands.
148
148
149
-
It's important to escape or remove `$` in input from user, files or network (_as bashbot does_).
150
-
One of the powerful features of Unix shells is variable and command substitution using `${}` and `$()` can lead to remote code execution (RCE) or remote information disclosure (RID) bugs if unescaped `$` is included in untrusted input (e.g. `$$` or `$(rm -rf /*)`).
149
+
It's important to escape or remove `$` and \` in input from user, files or network (_as bashbot does_).
150
+
One of the powerful features of Unix shells is variable and command substitution using `${var}`, `$(cmd)` and \`cmd\` can lead to remote
151
+
code execution (RCE) or remote information disclosure (RID) bugs if unescaped `$` or \` is included in untrusted input (e.g. `$$` or `$(rm -rf /*)`).
151
152
152
153
A powerful tool to improve your scripts is `shellcheck`. You can [use it online](https://www.shellcheck.net/) or
153
154
[install shellcheck locally](https://github.com/koalaman/shellcheck#installing). Shellcheck is used extensively in bashbot development
@@ -241,4 +242,4 @@ See `mycommnds.sh.dist` for an example.
241
242
242
243
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
0 commit comments