<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Dmitry,<br>
Please see answers below...<br>
Yours sincerely,<br>
Pierre<br>
<br>
<div class="moz-cite-prefix">Le 20/12/2016 19:21, Dmitry Bakshaev a
écrit :<br>
</div>
<blockquote
cite="mid:CAK9DdiGjGHMEJ=3e+cc8NX7my3ucJ7PaSB+r8rmS0PsqF=785w@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">2016-09-29 19:52 GMT+04:00 Pierre
Delaage <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:delaage.pierre@free.fr" target="_blank">delaage.pierre@free.fr</a>></span>:</div>
<div class="gmail_quote">Hi Pierre</div>
<div class="gmail_quote"><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">Shortly speaking : per user envvars
are meaningless for WCE ..phones, as there is no way to
switch from a user to another on those devices. At a
time WCE was used on "handeld PC", where things could be
slightly different.<br>
So I recommend that, when your customized stunnel is
loading conf file, and after you have "tokenized" the
file to get env-vars name,<br>
you mimic system calls with a stub that always return
the same values RELATIVE to "." folder,<br>
ie where the stunnel executable has been installed on
the phone.<br>
This is the SOLE path that is reliable on a WCE phone.<br>
<br>
Clearly, your envars will be "path to something" I guess
: typically path to the cert file.<br>
for this example your cert file on a phone will always
be in "./mycert.crt".<br>
<br>
</div>
</blockquote>
<div><br>
</div>
<div>
<div>1. again from beginning:</div>
<div>different OS has different rules,</div>
<div>different filename syntax: /home/... /etc/...
"C:\Document and Settings", "C:\Users", </div>
<div>different environment variables: "USER" on *nix,
"USERNAME" on windows or none on others like WinCE,</div>
<div>stunnel has platform specific options: chroot=,
setuid=, setgid=, pid= ... </div>
<div><br>
</div>
<div>we not target for "one config file for all users in
the world",</div>
<div>we target "one config file for all users on this
system",</div>
<div>and config may use (not necessary) these platform
specific features or not.</div>
<div>for example WinCE may be only specified directly: </div>
<div>cert = ./mycert.crt</div>
<div>on Windows through USERPROFILE:</div>
<div>cert = %USERPROFILE%\.certs\my.p12</div>
<div>or directly (in personal config file)</div>
<div>cert = "c:\Users\john\Desktop\New Folder\my.p12"</div>
<div>on *nix through HOME:</div>
<div>cert = ${HOME}/.certs/my.p12</div>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF"> For a win32 platform, there will
be either a system wide stunnel running (so who will set
up envvars to give to the stunnel env ?
</div>
</blockquote>
<div><br>
</div>
<div>2. only the necessary and known variables substituted
in the configuration file, other values specified as
usual.<br>
</div>
</div>
</div>
</div>
</blockquote>
There were 2 questions in 1 on my side, and you answered only on the
conf file part, so I repeat my question :<br>
on a win32 system, in your plans, will there be ONE system-wide
stunnel running (so that per-user envvar customization is useless),<br>
or do you plan to have "multiple" stunnel running simultaneously ?
(something quite strange unless you customize every ip and/or ports
in stunnel conf...but why?)<br>
or ... just one stunnel process running, for THE whole system, for
the currently logged-in user ? (in that case, if THE user is
starting stunnel, one conf file installed with stunnel, and remotely
managed by the admin, can be enough; and if the pb is to get access
to a personal cert file, a generic "./" path into the conf file is
enough).<br>
<blockquote
cite="mid:CAK9DdiGjGHMEJ=3e+cc8NX7my3ucJ7PaSB+r8rmS0PsqF=785w@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF"> another system script ? </div>
</blockquote>
<div><br>
</div>
<div>3. no. standard way to set envvars from Windows GUI
(for example, from Google):</div>
<div><a moz-do-not-send="true"
href="https://www.nextofwindows.com/how-to-addedit-environment-variables-in-windows-7">https://www.nextofwindows.com/how-to-addedit-environment-variables-in-windows-7</a><br>
</div>
<div>administrator may set "System variables" globally,</div>
<div>regular user may set only "User variables".</div>
<div>also from</div>
</div>
</div>
</div>
</blockquote>
This is not the only way to set envvars; registry hacks can ALSO do
the job, particularly from malicious code...<br>
<blockquote
cite="mid:CAK9DdiGjGHMEJ=3e+cc8NX7my3ucJ7PaSB+r8rmS0PsqF=785w@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div> <br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">with the risk that this script be
modified by malicious code ?),<br>
</div>
</blockquote>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF"> or a "one user at a time"- wide
stunnel running : it will not be possible to get many
processes running stunnel at the same time (just
because, whatever envvar you use, all your processes may
conflict when listening to "accept" sockets) unless ...
you customize "accept" port through envvars ?<br>
for me this is quite dangerous : customizing accept or
-even more dangerous- connect ports through envars is
really easy in user space for any malicious code (to
redirect the trafic..).<br>
</div>
</blockquote>
<div><br>
</div>
<div>4. the administrator decides which of the configuration
parameters can be changed by substituting the values of
the environment variables,</div>
<div>choosing between security and management flexibility:<br>
</div>
<div>from nothing to customize "accept" port through
envvars, if it is required.<br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF"> So I still do not see clearly the
interest for stunnel to decode envvars on the fly in
conf file.<br>
<br>
If you are looking for conf file automated generation on
large sites, I already gave the trick in a 1-line sed
command :<br>
<pre>cat stunnel_template.conf | sed -r -e "s/^(.*)$/C\:\\Progra~2\\<wbr>GnuWin32\\bin\\echo.EXE \1/e" > stunnel.conf</pre></div></blockquote><div>5. if machine joined into domain, administrator adds new user into AD, we need manually update/generate new config files? run it from Group Policy?</div><div>also we need regenarete all config files on changing stunnel_template.conf?</div><div>by substituting variables is not necessarily - only one shared config file, centrally managed by the administrator.
</div></div></div></div></blockquote>At a time or another, if you are running in an AD environment, users will login and execute some script downloaded from the server.
Refreshing their conf file at that time is like updating any other setting or sw in the system.
In any case updating stunnel-conf--template will require a new download of the template on client systems.
<blockquote cite="mid:CAK9DdiGjGHMEJ=3e+cc8NX7my3ucJ7PaSB+r8rmS0PsqF=785w@mail.gmail.com" type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">
You may argue that this trick can lead to same security breach than
explained above ...but ... NOT for system-wide stunnel for which
-normally- the stunnel.conf file can NOT be modified.
Even for system-wide stunnel, any malicious sw that can tweak the
system registry will be able to redirect stunnel trafic...
</div></blockquote><div>
</div><div>6. if we need static system-wide stunnel.conf, we simple write it without envvars. exactly the same as it is now.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">
So this is why I do not encourage this patch.
</div></blockquote><div>
</div><div>7. I think that the discussion about "hack regisrtry", "malicious sw", etc. should be considered in the context of the overall security of the Windows operating system, not stunnel context.</div><div>
</div><div><div>"by disign" any multiuser operating system has "user privileges separation" for user files, processes, and other objects, like Windows registry, environment variables &etc.</div><div>regular user is not allowed to modify objects of other users.
</div><div>when start user session with other credentials through "sudo" on *nix/"run as" on windows,
</div><div>system "reset" environment and build it from scratch, merging default "System variables" with "User variables" of the new user.</div><div>on Windows services start under SYSTEM account ("local system" , "LocalSystem" ...), which has own profile, registry branch, environment variables.
</div><div>only administrator may change their.</div></div></div></div></div></blockquote>The main pb is that :
1/ system envvars can be overiden in user context : and it is quite straightforward in <u>user </u>context to ... modify <u>user </u>variable overiding system variables...
by any software (malicious or not) (<a class="moz-txt-link-freetext" href="https://support.microsoft.com/en-us/kb/100843">https://support.microsoft.com/en-us/kb/100843</a>)
2/ As user can modify THEIR envvars, how an admin can be sure that stunnel per-user conf file is working as expected (by the admin...)
3/ per user conf file in a system means that stunnel is NOT running as a system wide process, but as a per-user process (probably in foreground) : so that one user (or malicious code) can easily stop it, modify conf file or restart stunnel with another one. In that case, all the work on the template can be circumvented.
So, for all that reasons, and considering that your goal can be achieved differently (sed and/or generic relative path etc...), I am still reserved on the patch.
Clearly it allows one to modify stunnel conf on the fly, for a sw that most of the time is used as a service and should not see its conf modified at all.
It is lowering the security of stunnel (by lowering, not to say suppressing, its conf file integrity) and the system.
<blockquote cite="mid:CAK9DdiGjGHMEJ=3e+cc8NX7my3ucJ7PaSB+r8rmS0PsqF=785w@mail.gmail.com" type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">
Apart from that, technically speaking, you can go forward by
creating a stub for getenv or expandstring w32 functions.
To setup a wce dev environment, see this page :
<a moz-do-not-send="true" class="gmail-m_-5287413194945903629moz-txt-link-freetext" href="http://delaage.pierre.free.fr" target="_blank">http://delaage.pierre.free.fr</a>
The link for evc4 is now broken : use this instead :
<a moz-do-not-send="true" class="gmail-m_-5287413194945903629moz-txt-link-freetext" href="http://download.microsoft.com/download/C/3/F/C3F8B58B-9753-4C2E-8B96-2DFE3476A2F7/eVC4.exe" target="_blank">http://download.microsoft.com/<wbr>download/C/3/F/C3F8B58B-9753-<wbr>4C2E-8B96-2DFE3476A2F7/eVC4.<wbr>exe</a>
I will refresh this web page later with more recent stunnel
codebase.
</div></blockquote><div>
</div><div>8. referring to p.1 we do not need to "emulate" envvars on platform that not has it.</div><div>the last version of the patch has already implemented empty stub for ExpandEnvironmentStrings function on WinCE platform.</div><div> </div><div>p.s.: some interresting links about envvars:</div><div><a moz-do-not-send="true" href="http://stackoverflow.com/questions/10090014/can-i-trust-my-environment-variables">http://stackoverflow.com/questions/10090014/can-i-trust-my-environment-variables</a>
</div><div><a moz-do-not-send="true" href="http://security.stackexchange.com/questions/119962/what-are-some-vulnerabilities-of-environment-variables-on-any-platform">http://security.stackexchange.com/questions/119962/what-are-some-vulnerabilities-of-environment-variables-on-any-platform</a>
</div><div><a moz-do-not-send="true" href="http://breakingmalware.com/vulnerabilities/elastic-boundaries-elevating-privileges-by-environment-variables-expansion/">http://breakingmalware.com/vulnerabilities/elastic-boundaries-elevating-privileges-by-environment-variables-expansion/</a>
</div></div></div></div>
</blockquote>
</body></html>