Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Issue: Trusted strings, shell escaping and backwards compatibility.

Open
#333 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
ruby, shell
Domain
devops, security

Research direction

Start by reviewing the discussion in #283 and the common execute() path used by test(), capture(), and execute(), then trace environment handling through with() and default_env. Determine the intended taint and escaping behavior for these entry points, including the proposed backwards-compatible warnings. Done means the behavior is agreed and its compatibility and failure cases are specified.

Written by the indexing model from the issue text.

Description

discuss!

@ncreuschling @mattbrictson /cc

Continuing from the discussion in #283 I'd like to raise the general issue of shell escaping (shellwords) and what we mean/expect about "escaping strings" and so forth, whilst closing #283 it came to my mind that Rails using Object#taint, Object#tainted? and family works mostly pretty well.

I want to unify behavior.

I would propose the following:

  • Identify where we want to escape things, if at all:
    • Arguments to test(), capture(), execute() etc (via the common execute() function)
    • Environment variables, and values when used with with(){}
    • Environment variables when used with default_env
  • Find out if strings are tainted or not by default in the Capistrano context.
  • Find a backwards compatible way to:
    • Issue a release with warnings for "tainted" strings in the places we care about, warning that behavior will change
  • See if it makes sense to compare untrusted (the trust vernacular is deprecated) against their shellescaped counterparts, and exit with an error in that case.

I'm afraid that strings coming from the same file that is running will be trusted by default, so the whole plan falls apart, I'd have to look more closely at the API to see if the default taint value for a string is tainted, untainted, or (ideally) none.

Ideally, this would mean, I could do something like this:

SSHKit.config.default_env = {
   "$MY_LITTLE_PONY".untaint => "i should however be escaped" 
}

This would lead to us calling a literal export $MY_LITTLE_PONY=i should however be escaped, for better or worse.

Dominant language
Ruby
Stars
1.2k
Forks
257
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from capistrano/sshkit

All issues in capistrano/sshkit

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.