Bug 53098 - mod_proxy_ajp: patch to set worker secret passed to tomcat
Summary: mod_proxy_ajp: patch to set worker secret passed to tomcat
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy_ajp (show other bugs)
Version: 2.2.22
Hardware: PC Linux
: P2 normal with 10 votes (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2012-04-18 06:49 UTC by Dmitry Bakshaev
Modified: 2020-04-17 21:30 UTC (History)
4 users (show)



Attachments
adding "secret" proxypass option (3.47 KB, patch)
2012-04-18 06:49 UTC, Dmitry Bakshaev
Details | Diff
apache 2.4 patch (3.48 KB, patch)
2016-04-08 09:19 UTC, Dmitry A. Bakshaev
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Bakshaev 2012-04-18 06:49:55 UTC
Created attachment 28630 [details]
adding "secret" proxypass option

apache httpd config:
ProxyPass /test ajp://localhost:8009/test secret=123

tomcat config:
<Connector protocol="AJP/1.3" requiredSecret="123" ... />
Comment 1 Jacob Champlin 2012-10-03 19:55:27 UTC
Voting for this bug because this is the only way to prevent someone from constructing a ajp request and sending it with a invalid username to a tomcat server.  This module should support this.
Comment 2 Dmitry A. Bakshaev 2013-05-24 16:03:57 UTC
example of more secure configuration.

main apache virtualhost file (world readable):

...
ProxyPass /test ajp://localhost:8009/test
#Include must be after ProxyPass
Include ajp_secrets.include
...

contents of ajp_secrets.include (only root readable):

...
ProxySet ajp://localhost:8009/test secret=123
...
Comment 3 David Naramski 2016-04-07 11:44:58 UTC
Voting to this because it's a way of securing connection between Apache Reverse proxy and target application server. 

It would be even better to have a "signature request mechanism" for some header. Like if the REMOTE_USER header is added by the reverse proxy, the header is signed in a REMOTE_USER_SIGNATURE field, using a private key stored on the reverse proxy.
Comment 4 Dmitry A. Bakshaev 2016-04-07 17:50:12 UTC
signature will require modification on the Tomcat side.
this patch only impliment Tomcat requiredSecret option for mod_proxy, like mod_jk does.
see https://tomcat.apache.org/connectors-doc/reference/workers.html (search for "secret").
security for frontend to backend communication may be done by localhost connection or by network topology (network switch), etc.

security for frontend to backend communication may be done by localhost connection or by network topology (network switch, etc.), because this is internal trusted link.
Comment 5 Dmitry A. Bakshaev 2016-04-07 17:51:45 UTC
this patch is worked with apache-2.4.18
Comment 6 Dmitry A. Bakshaev 2016-04-08 09:19:32 UTC
Created attachment 33739 [details]
apache 2.4 patch
Comment 7 David Naramski 2016-04-11 07:20:59 UTC
(In reply to Dmitry A. Bakshaev from comment #4)
> signature will require modification on the Tomcat side.
> this patch only impliment Tomcat requiredSecret option for mod_proxy, like
> mod_jk does.
> see https://tomcat.apache.org/connectors-doc/reference/workers.html (search
> for "secret").
> security for frontend to backend communication may be done by localhost
> connection or by network topology (network switch), etc.
> 
> security for frontend to backend communication may be done by localhost
> connection or by network topology (network switch, etc.), because this is
> internal trusted link.

You're right, I've created a new request for this signature idea : 59285 (https://bz.apache.org/bugzilla/show_bug.cgi?id=59285). 

This will permit to the application to treat this field without changing the Tomcat connector.
Comment 8 Dmitry A. Bakshaev 2016-04-11 09:51:37 UTC
(In reply to David Naramski from comment #7)
> You're right, I've created a new request for this signature idea : 59285
> (https://bz.apache.org/bugzilla/show_bug.cgi?id=59285). 
> 
> This will permit to the application to treat this field without changing the
> Tomcat connector.

why not use ssl for backend connection?

integrity, encryption, transparently for both sides

mod_proxy can do it for http.
not sure about mod_proxy_ajp and tomcat ajp-connector.
Comment 9 Yann Ylavic 2016-04-11 11:28:45 UTC
(In reply to Dmitry A. Bakshaev from comment #8)
> 
> why not use ssl for backend connection?
> 
> integrity, encryption, transparently for both sides

Agreed.

> 
> mod_proxy can do it for http.
> not sure about mod_proxy_ajp and tomcat ajp-connector.

mod_proxy_ajp can also be configured to use TLS connections and PKI.
Comment 10 Rainer Jung 2016-04-11 15:09:29 UTC
Yann, are you aure about proxy_ajp and TLS? I thought the TLS part is only inside proxy_http but I could be wrong. Of course one can use technology outside of httpd like stunnel.

I also would be very surprised, but positively surprised, if we would find a way on AJP servers (Tomcat, Jetty) to configure AJP over TLS there.

Regards,

Rainer
Comment 11 Yann Ylavic 2016-04-11 16:41:17 UTC
Hmm, you are right, I thought "ajps:" was handled but it's an overlook on my side.
It shouldn't be too much pain to add it though, if Tomcat is already good to go, most of the code to handle TLS is in proxy_util.
I could try to cook a patch...
Comment 12 jdennis@redhat.com 2016-04-11 17:03:50 UTC
The subject of this bug report is adding support to include the "secret" AJP field. Please do not confuse things by bringing in other topics such as AJP support for TLS, instead open a new bug report for that independent issue.

Now back to the actual topic of this bug. A simple non-controversial patch has been available since this bug was opened 4 years ago. Yet 4 years later it still has not been applied. Why?
Comment 13 Yann Ylavic 2016-04-12 10:31:41 UTC
(In reply to jdennis@redhat.com from comment #12)
> Now back to the actual topic of this bug. A simple non-controversial patch
> has been available since this bug was opened 4 years ago. Yet 4 years later
> it still has not been applied. Why?

Maybe because a stronger authentication method is possible by using an https connector? Not ajps though (I stand corrected!), but AFAICT current Tomcat versions can be configured to use https and hence TLS authentication.

Please keep in mind that committers are volunteer here, with limited time devoted to most important tasks, in their opinion...

The point is, IMHO, that a secret sent in clear text in not very secure.
Either the network between httpd and tomcat is controlled and an (week) authentication is not needed, or the network is unsafe and a stronger authentication is required.
Comment 14 jdennis@redhat.com 2016-04-12 13:02:11 UTC
I suspect everyone is in agreement that the transport needs to be protected for this to be useful. But lets not get the cart before the horse, protected transport only becomes an issue *after* this omission in the AJP protocol generation is fixed. That's all this bug report is asking for, to correct the omission. The patch is available, it's not hard. Nobody would be forced to use the feature so it doesn't make anything less secure. But as it stands now if you do want to use it, perhaps you have a protected transport available to you, you can't use it because the AJP protocol generator oddly omits the attribute.

We want to use the attribute. We'll worry about the separate issue of protected transport elsewhere. Make sense?
Comment 15 Dmitry A. Bakshaev 2016-04-12 17:34:51 UTC
this patch just adds lost functionality to mod_proxy_ajp, a lot of time working in mod_jk+tomcat.

no new features.

a typical usage scenario:
client(browser) - https(internet) - apache httpd(ssl-termination-acceleration) - mod_proxy_ajp - ajp - localhost(trusted area) - apache tomcat(application)

"secret" need to "bind" multiple url on apache httpd to multiple tomcat instances or connectors one-to-one, to protect from fake ajp requests from other application and users from same host(localhost).

"secret" works like "identification", not crypto-blablabla...

ssl,encryption&etc is separate question.
Comment 16 Yann Ylavic 2016-04-12 23:44:00 UTC
(In reply to jdennis@redhat.com from comment #14)
> We want to use the attribute. We'll worry about the separate issue of
> protected transport elsewhere. Make sense?

(In reply to Dmitry A. Bakshaev from comment #15)
> this patch just adds lost functionality to mod_proxy_ajp, a lot of time
> working in mod_jk+tomcat.

Fair enough, there seem to (still) be attraction to it, so committed in r1738878, let's see what others say...

> 
> a typical usage scenario:
> client(browser) - https(internet) - apache
> httpd(ssl-termination-acceleration) - mod_proxy_ajp - ajp -
> localhost(trusted area) - apache tomcat(application)
> 
> "secret" need to "bind" multiple url on apache httpd to multiple tomcat
> instances or connectors one-to-one, to protect from fake ajp requests from
> other application and users from same host(localhost).

I can grok the "isolation" argument (prevent requests from reaching unexpected services), but not the security one.
This is definitively not a security feature (like SSLv2 isn't anymore), and shouldn't be presented as such.
As I said earlier, either localhost is trusted or it is not, and in the latter case "secret" won't change anything (significantly).

> 
> "secret" works like "identification", not crypto-blablabla...
> 
> ssl,encryption&etc is separate question.

This is called "authentification" in crypto, not blah, and it's probably the only way to achieve security goals, if any...
Comment 17 jdennis@redhat.com 2016-04-12 23:57:49 UTC
Thank you!
Comment 18 Dmitry A. Bakshaev 2016-04-13 17:22:50 UTC
thanks to all
Comment 19 Rainer Jung 2020-02-22 07:41:00 UTC
It would be useful to backport this eature to 2.4.x.
The newest Tomcat releases hardened the AJP connector by demanding a "secret" by default, so they are no longer compatibel with mod_proxy_ajp out-of-the-box. One has to explicitly set secretRequired="false" on the TC AJP connector to be able to use it with mod_proxy_ajp (and thereby increase attack surface).

r1738878 plus small struct layout adjustments for compatibility should do it.
Comment 20 Rainer Jung 2020-02-24 19:21:02 UTC
Backported today to 2.4.x as r1874456, will be part of 2.4.42.
Comment 21 Konstantin Kolinko 2020-02-26 12:29:35 UTC
(In reply to Rainer Jung from comment #20)
> Backported today to 2.4.x as r1874456, will be part of 2.4.42.

Thank you!

The secret is also documented (not yet backported to 2.4.x) in
https://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_proxy_ajp.xml?view=markup


Caveat: mod_proxy_ajp.xml refers to old attribute names
<code>request.secret</code> or <code>requiredSecret</code> of Tomcat,
which are now just "secret". I updated a similar reference in mod_jk documentation in the following commit:
https://github.com/apache/tomcat-connectors/commit/83dc3e486509cf63b0c478b46d75b4b886088652
Comment 22 Patrik S. 2020-03-19 09:35:48 UTC
Because of Ghostcat CVE-2020-1938 may I ask you, when (in detail) the 2.4.42 release will be out?
After the tomcat side could be hardened, we can not do it, because of missing support on the other side in Apache reverse proxy. :-(
Comment 23 Grant G 2020-04-17 20:55:37 UTC
Agreeing with Patrick, we need this released so we can resolve issue with Tomcat updates.
Comment 24 Rainer Jung 2020-04-17 21:30:00 UTC
2.4.42 failed the release vote, but in te meantime 2.4.43 has been released, which contains this feature.