Subject: Bug#1465: [X2Go-Dev] Bug#1465: Bug#1465: Bug#1465: Allow running with restricted shell (rbash), or limit applications that can be run.

From: Vladislav Kurz <[email-masked]>
Date: Mon, 04 May 2020 15:34:22 +0200

Hello,

I'm not sure If I should post to @bugs.x2go.org or x2go-dev mailing list.

Dne pondělí 4. května 2020 14:30:26 CEST, Stefan Baur napsal(a):
> Am 04.05.20 um 14:06 schrieb Ulrich Sibiller:
> > On Mon, May 4, 2020 at 1:15 PM Stefan Baur <[email-masked]> wrote:
> >> You need to realize the truth: What a user can see (as in "access"),
> >> they can copy.
> > 
> > Well, I basically agree with what you wrote. But the OP was mentioning
> > he just wants to provide _one_ single published application.
> > 
> > Now let us assume some pre-conditions:
> > - the application is unable to display the data you want to protect.
> > If not, all the ways you mocked up above could be used and the
> > approach will not work
> 
> And that's the catch: If the application can't display the data - then
> why would the user need access to it at all?  chmod/chown it away from
> them and you're good to go.  But obviously the data is needed *somehow*,
> or else they wouldn't have the problem of wanting to hide it from the user.

I have to explain it. The protected thing is openoffice sheet with some complex 
formulas. The formulas should be protected from viewing by openoffice somehow 
(that was not my task so I did not really check that in detail). Users fill in 
input data, get the results, and can print them via CUPS to PDF (or paper). We 
do not want them to get the sheet and use it elsewhere. They are allowed to 
make work copies of the sheet within the protected environment, but should not 
be able to get it out.

So openoffice is the only application they are supposed to run.
I do not want them to be able to run shell at all. Ideally, they should be 
kicked away if they log in with plain ssh.

> X2GoClient has file sharing built in.  It's easy to hide the feature,
>  but users that know that it's there may still be able to use it.

I managed to block file transfer in x2go - by uninstalling fuse on server. 
Although it would be nice to have some switch to disable it server side, and 
allow fuse for other uses.

> Web browsers allow upload forms.  And JavaScript, which could also be
>  used for a QR encoder.
> Command line web browsers like lynx, elinks, even wget and curl can be
>  used to upload files.

The environment is quite limited and all browsers and similar stuff was either 
uninstalled or chmod 750, so that only root or trusted users can run run it.
Especially xterm, so that there is no reasonable way to run shell via x2go.
openoffice is the only x-application installed.

> They could also use professional screengrabbing equipment...

Using camera to make a screenshot is not a problem. The results of the 
calculation are not protected.

> > Then all we'd need was
> > - a restricted ssh-key that only allows for the commands that are
> > required for the x2go session handling
> 
> Which doesn't work out of the box.  You can specify exactly one command.
> To be able to use more than one, you need a wrapper script on the host
> that is set as forced command, which then parses $SSH_ORIGINAL_COMMAND.
> These scripts are notoriously bad to maintain, error-prone, and while
> they work with scripted commands (e.g. running an automated rsync job
> with varying target directories), they suck hard for interactive use.

That was doing the wrapper mentioned in my original post. I don't know what 
commands are sent by the x2go client. But if it would be just one command that 
it could be put into the ssh forced command.

If I would not need x2go for bandwidth reasons, I would just put oocalc in 
forced commands and use ssh -X. That would provide the protection level I'm 
aiming for.

> > Also, IIRC Mihai added an explicit bash call into certain commands to
> > make it work fur users with a different login shell. And obviously the
> > original rbash instructions worked before. So you could also try to
> > set that up and do some research where to remove the explicit bash
> > calls.
> 
> Given that bash is enforced there for a reason, it doesn't sound like a
> good idea to replace it with something else.

I do not want to replace it. Just need to execute the script like:
x2goruncommand ...    (to let it be found in $PATH)
and not 
bash /usr/bin/x2goruncommand ...
That will let me use rbash which is close to what I need.

The question is where is this call written? Can I modify it myself?
I was trying to find it on server side but failed.

Best Regards
Vladislav Kurz