After upgrading OOD from 4.0.8 to 4.1.1, an interactive application using ttyd no longer works. The ttyd application was developed based on the following URL:
Thanks for finding that. I was looking at workarounds and alternatives yesterday. I still like ttyd but the maintainer doesn’t seem to be interested in adding alternative auth options. I’m already making a slight modification when building ttyd to add the basic auth credential via an environment variable instead of the -c flag.
Also considering if using the --auth-header option would work well here and be secure but it only currently seems to check for the existence of the header and not the value. So possibly with some more updates to ttyd an additional parameter could be passed via the script.sh.erb with the owner’s userid.
Did you all update OnDemand on the same machine? I’ve got a dev instance running with trace7 turned on, but it’s unclear where/how these values are being parsed out and then passed downstream.
So I’m wondering if this came from OnDemand updates or apache updates. Googling around, putting the username & password in the URL seems to be deprecated and indeed browsers themselves may not even be passing this information.
In any case, I’m still trying to track down where and how this is being parsed in apache and passed to the origin.
I think I figured out why this isn’t working. Asking the correct question in google provides the answer: The browser strips this from the URL and sends it in an Authorization header.
For additional security 4.1 started to strip these headers when making requests downstream to origin servers.
strip_proxy_headers in ood_portal.yml is now stripping the Authorization header to the origins to actually prevent this exact situation. It’s in the default configuration, so updating this configuration to allow Authorization to pass through should fix your issue.
Thanks for digging into this issue. This was already a fragile setup for ttyd auth, so it feels like the better long-term fix is to make the changes to ttyd. I’ve already updated our instances to my new fork and have heard no complaints from users yet.
Although it doesn’t seem to get a ton of updates, I’m just not sure how difficult it will be to maintain longer term and the maintainer appears to be unwilling to incorporate the changes.
Sorry for the delayed response. Due to a system power outage, my verification was delayed.
I have now confirmed that ttyd works if I configure strip_proxy_headers to remove only the Authorization header. However, I understand that this is not a recommended configuration from a security perspective.
Therefore, either:
Using the fork maintained by hansen-m, or
Finding an alternative approach
will be necessary for a proper solution.
Since the original purpose of this ticket (confirming that the default ttyd does not work as-is) has been achieved, I will finish this ticket.
-b: Specifies the expected base path for requests coming from a reverse proxy. By including /${PASSWORD} in the base path, the one-time password becomes part of the URL.
-c: Enables BASIC authentication. Since we are not using BASIC authentication in this approach, this option is removed.
-W: Enables write access.
-m 1: Limits the maximum number of clients to 1.
Instead of using BASIC authentication (-c), access control is handled by embedding a random token directly in the URL.
Next, I define the password in template/before.sh, as follows:
Perhaps I’m missing something but doesn’t this just result in an obscured base path but still open URL for access to the session? Other users who discovered (fromps output) or were provided the link would have full access to that user’s shell. Only the client limit of -m 1 would prevent them from connecting.
When I checked the ttyd GitHub repository, I found some PRs that aim to improve security. However, as you mentioned, it doesn’t seem likely to be merged anytime soon.
So I went ahead and forked it myself:
The modification to src/server.c is very minimal - just 16 lines in total. Instead of using the -b option, it introduces an environment variable, TTYD_BASE_PATH.