Bug 815 - RFE: sshd should be able to set environment variables defined by the client
Summary: RFE: sshd should be able to set environment variables defined by the client
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: -current
Hardware: All All
: P2 enhancement
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords: patch
Depends on:
Blocks: 822
  Show dependency treegraph
 
Reported: 2004-03-21 11:00 AEDT by Roland Mainz
Modified: 2004-09-11 13:18 AEST (History)
0 users

See Also:


Attachments
Implement environment passing (9.58 KB, patch)
2004-03-30 13:58 AEST, Damien Miller
no flags Details | Diff
Revised environment passing diff (14.16 KB, patch)
2004-04-27 12:28 AEST, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Mainz 2004-03-21 11:00:11 AEDT
RFE: sshd should be able to set environment variables defined by the client,
e.g. it should be possible that the user defines a value of an environment
variable as part of the "ssh" command-line arguments and "sshd" then sets that
environment variable for the application to execute.
Comment 1 Damien Miller 2004-03-21 18:46:00 AEDT
If we implement this, we will probably only do it for a couple of environment
variables (LANG and maybe LC_*) as passing arbitrary environment variables
provides new opportunities for a user to break out of restricted shell.
Comment 2 Roland Mainz 2004-03-22 00:28:32 AEDT
Damien Miller wrote:
> If we implement this, we will probably only do it for a couple of environment
> variables (LANG and maybe LC_*) as passing arbitrary environment variables
> provides new opportunities for a user to break out of restricted shell.

Good idea. I suggest to add support for filtering name=value pairs via extended
regex pattern - one "accept" pattern and one "reject" pattern.

Anything which matches the "accept" pattern and doesn't match the "reject"
pattern should be accepted.

accecpt_pattern should look like this ("match all" for now):
".*=.*"

reject_pattern should look like this (kill linker and ssh env vars... and
DISPLAY since that's used by the X11 forwarding code):
"(^LD.*=.*|^SSH.*=.*|^DISPLAY.*=.*)"

Generally whitelisted should be:
CVSROOT
CVS_RSH
LANG
LC_MESSAGES
LC_TIME
LC_NUMERIC
LC_CTYPE
LC_MONETARY
LC_COLLATE
LC_PAPER
LC_ALL
LPDEST       (used by print spooler to set default printer)
PRINTER      (used by print spooler to set default printer)
PDPRINTER    (used by print spooler to set default printer)
XPRINTER     (used by Xprint - see http://xprint.mozdev.org)
XPSERVERLIST (used by Xprint - see http://xprint.mozdev.org)
TZ           (timezone)
MAIL         (unix mail folder location)
Comment 3 Damien Miller 2004-03-30 13:58:47 AEST
Created attachment 578 [details]
Implement environment passing

The attached patch implements environment passing for -current. 

ssh gains an option "SendEnv", which specifies which environment variables may
be sent. sshd gains "AllowEnv", which controls what environment variables are
accepted (I don't much like this option, it may go away in favour of a fixed
list). 

Both of these options may be specified multiple times (with cumulative results)
and both take basic "*" and "?" wildcards.

This needs testing, especially with non-OpenSSH implementations.
Comment 4 Roland Mainz 2004-03-31 03:00:02 AEST
Damien Miller wrote:
> ssh gains an option "SendEnv", which specifies which environment variables may
> be sent. sshd gains "AllowEnv",

What about the explicit "reject" list ?

> which controls what environment variables are
> accepted (I don't much like this option, it may go away in favour of a fixed
> list).

A hardcoded list may be bad. If someone finds a possible exploit via the
"env-var"-forwarding it may be a good idea to have a quick way for admins to
block the env var used for that.
Comment 5 Markus Friedl 2004-03-31 06:25:17 AEST
reject lists are bogus.

default should be 'deny'.
Comment 6 Damien Miller 2004-04-27 12:28:38 AEST
Created attachment 620 [details]
Revised environment passing diff

Revised diff with a couple of changes:

- Manpages
- s/AllowEnv/AcceptEnv/ in sshd_config, so hopefully people won't 
  expect a symmetric DenyEnv (like the other Allow options)
- Regress test
- Passed env vars get added only if !use_login
Comment 7 Damien Miller 2004-04-27 19:47:33 AEST
This has been committed and will be in 3.9