Java and proxies

Status
Not open for further replies.
i manage the proxies for my company, and it has long been a policy that we force authentication. where we cant do Kerberos or NTLM (Basic is forbidden), we allow auth bypass based on 3 criteria: Source IP(s), User-Agent string, Destination URL(s).

this has served us well until our java developers started having to use explicit proxies. it seems that they have never had to use an explicit proxy and it aggrevates the hell out of me because i have to resort to learning how to do their job, and tell them how to code their apps in this environment.

i have to tell them to use the CONNECT Method to establish an SSL session. i have to tell them that all subsequent PUT/POST/GET/etc Methods must be tunneled through the SSL session established with the CONNECT Method. sometimes they get this. other times, i resort to giving them an example that was given to me by someone who figured it out. that example is in Apache Commons, but a lot of the devs i interact with are using Pure Java (think Mule), so its not a 1-to-1 example.

now i have a fellow that needs to connect to an external site and the CONNECT Method has a User-Agent string present. the Client Hello is issued, but the proxy rejects the connection before the Server Hello is given back to the client. i know for sure this has to do with the User-Agent string, because if i remove that requirement, and allow access based on Source IP and Destination URL only, the connection works.

i am told the client app is written in Apache C#, which is written in Java and uses the Java User-Agent string (Java/1_7.blah). i could be wrong about the name of the language but have captured the UA string. if the language is pertinent, i will get the exact name.

we get on a call, and another dev gets on and tells me that he has never heard of the UA being exposed. he starts in on the Host header, which i believe is never exposed outside of SSL. they are different headers, and are apples-to-oranges for all i care. he then tells me to point him at resources to explain this. i think i am going to tell him to EFF off and go find it himself. i am not a developer, and its not my job to research how he/they have to write code to fit within the requirements of the infrastructure. i only have to give him requirements, which i have more than done.

i have dealt with enough HTTP and SSL, as owner of the proxies, and i know for a fact that the UA header can be exposed outside any encryption. i also know that it sometimes is not present or can be moved into the encrypted side of the conversation. at this point, i no longer remember where i came across this knowledge, but i am absolute on it. moreover, i have other client apps using SSL and auth bypass that do work using the same 3 criteria. the difference there is that most of those apps are shrink wrapped apps from a vendor.

so, here i am looking to find someone who might have more of a clue than me (and the devs i work with, it seems) about java and its user-agent string. how does one force java to expose the UA string for all requests, etc? for some reason, i think java can be configured to behave the way i expect it to work, but i am not sure if i am right. any examples would be greatly appreciated, as would any online resources that i can point the devs at.
 

Blacken00100

Ars Legatus Legionis
10,130
Subscriptor
I've literally never heard of exposing a header outside of HTTPS; that's kind of the point of its existence. Can you show me a packet dump of an HTTPS request that does this?

i am not a developer, and its not my job to research how he/they have to write code to fit within the requirements of the infrastructure.

You must be a charmer to work with. It is your job to enable your coworkers to get shit done in your odd and nonstandard environment, isn't it?
 

Joel_B

Ars Praefectus
4,652
Subscriptor
[url=http:/civis/viewtopic.php?p=27868263#p27868263:4culdnet said:
brendan_kearney[/url]":4culdnet]i manage the proxies for my company, and it has long been a policy that we force authentication. where we cant do Kerberos or NTLM (Basic is forbidden), we allow auth bypass based on 3 criteria: Source IP(s), User-Agent string, Destination URL(s).

this has served us well until our java developers started having to use explicit proxies. it seems that they have never had to use an explicit proxy and it aggrevates the hell out of me because i have to resort to learning how to do their job, and tell them how to code their apps in this environment.

i have to tell them to use the CONNECT Method to establish an SSL session. i have to tell them that all subsequent PUT/POST/GET/etc Methods must be tunneled through the SSL session established with the CONNECT Method. sometimes they get this. other times, i resort to giving them an example that was given to me by someone who figured it out. that example is in Apache Commons, but a lot of the devs i interact with are using Pure Java (think Mule), so its not a 1-to-1 example.

now i have a fellow that needs to connect to an external site and the CONNECT Method has a User-Agent string present. the Client Hello is issued, but the proxy rejects the connection before the Server Hello is given back to the client. i know for sure this has to do with the User-Agent string, because if i remove that requirement, and allow access based on Source IP and Destination URL only, the connection works.

i am told the client app is written in Apache C#, which is written in Java and uses the Java User-Agent string (Java/1_7.blah). i could be wrong about the name of the language but have captured the UA string. if the language is pertinent, i will get the exact name.

we get on a call, and another dev gets on and tells me that he has never heard of the UA being exposed. he starts in on the Host header, which i believe is never exposed outside of SSL. they are different headers, and are apples-to-oranges for all i care. he then tells me to point him at resources to explain this. i think i am going to tell him to EFF off and go find it himself. i am not a developer, and its not my job to research how he/they have to write code to fit within the requirements of the infrastructure. i only have to give him requirements, which i have more than done.

i have dealt with enough HTTP and SSL, as owner of the proxies, and i know for a fact that the UA header can be exposed outside any encryption. i also know that it sometimes is not present or can be moved into the encrypted side of the conversation. at this point, i no longer remember where i came across this knowledge, but i am absolute on it. moreover, i have other client apps using SSL and auth bypass that do work using the same 3 criteria. the difference there is that most of those apps are shrink wrapped apps from a vendor.

If you know something like this to be "absolute" then you should be able to back it up in some way. Either by reproducing it or by providing information that demonstrates it. If some person was stating something like this to me and then not backing it up I would explain the situation to my supervisor and that the person was gate-keeping useful knowledge.

If you can't produce such information then say so to the Developers. Let them find this out since this is their job.
 
thankfully, another dev has rung in on this and explains it better than i can. the crux of it is the SSL session is setup with the CONNECT Method, and all other Methods must be tunneled through the established SSL session. i hammered this home to the original dev, but he did not understand this and does not know how to code it, either.

what happens is he sets up a SSL session and then issues the subsequent Method outside the tunnel. this causes the 3 criteria to not be met. when you issue a Method for HTTPS and are not in an explicit proxy environment (no proxy or transparent proxy env), the UA header does not have to be exposed. when the proxy sees that the UA is missing, it blocks the access because it requires it to be present for all NEWLY ISSUED Methods.

if the subsequent Method was tunneled, the proxy would not expect to see the UA header, and would not be blocking the access.

this exact scenario is something i indicated as being problematic when i first started working with this dev. i specifically went over this scenario. i even gave him example code in a different flavor of Java to demonstrate the process. while the example i gave is not an exact match to his flavor of java, he demonstrated why he does not deserve his job. he either outright ignored me and did not attempt to research this, or is utterly incompetent and cannot understand this.

i dont care what my attitude is or if i give people the warm and fuzzies. i am not employeed to make friends. i have a job to do and i take it seriously. if someone gives me a lot of relevant but not exactly-fitting-into-my-environment kind of information, i am going to research it. i am not going whine and escalate about impediments that are mine to overcome, but push them on someone else, as has been done to me by nearly every dev that has come to me for proxied access.

in no way shape or form was i gate-keeping. i am not a developer, and to the best of my ability i spoke to them at their level about the requirements of the envirionment. i provided the requirements of the proxies, which is all i am required to do. i gave specific examples of pitfall scenarios, and how to avoid them. i outlined high level proocess and left implementation to the supposed professionals. i went above and beyond to give this dev a leg to stand on and get his stuff working because i have to deal with what does not work when it is pushed on me. for all of that, i get to bang my head against a wall because they dont know how to do their job and dont put the effort into learning it when pointed in the direction needed?

now, after all of that, i go out and reach out to this board to research what they should know or be researching themselves, and you give me attitude about not helping or being an pain about it? be glad we dont work together,
 

ramases

Ars Tribunus Angusticlavius
9,024
Subscriptor++
Because CONNECT is a plain HTTP method (that should only be made through https, and is defined in a RFC that also specifies upgrading a http connection to https, but i've not found categorical language that outright states you may not issue a connect request via regular http, however ill-conceived that idea might be) -- the payload itself is actually just a tcp stream, its not necessarily another http request, but if it is it has its own discrete http header -- any http header can be added to it.

Since the CONNECT request is sent to the proxy server, it will, of course, be able to read any of those http headers because it is the ssl termination point for the connect request. Indeed it must be the ssl termination point, because the Host-Header is used to indicate to the proxy which host it should forward the proxied tcp stream to; if the proxied tcp stream is a plain http connection, of course the proxy will be able to read that, too, but if the proxied stream is something like https, or ssh, or another encrypted request, the stream will be opaque to the proxy (d'uh).

That being said, IMHO adding the user agent string to the proxy bypass rule does not add noticeable security to what is not already provided by the allowable-source/destination-tuple ruleset, and as such reeks of cargo cult security..

[url=http:/civis/viewtopic.php?p=27871521#p27871521:384wmw1w said:
brendan_kearney[/url]":384wmw1w]i even gave him example code in a different flavor of Java to demonstrate the process. while the example i gave is not an exact match to his flavor of java, he demonstrated why he does not deserve his job. he either outright ignored me and did not attempt to research this, or is utterly incompetent and cannot understand this.

This is not a "flavor of java" thingy; Java itself has no http clien; well, strictly speaking it does have URLConnection, and HTTPURLConnection. However, the amount of boilerplate that is required to be written to use that directly is substantial, and puts the onus on you to get all of it done without making a mistake; something you can avoid by simply using one of the number of available high-quality http client libraries. Which is what your devs likely (hopefully?) do.

If they do that the method to set up the http headers sent on a request will be at least partially specific to that library; there are a number of JVM parameters that can be used to set the behavior of connections made directly through classes like URLConnection, but the library will not necessarily heed them, or heed them in the same way.

To be honest, even if you are not a developer but a sysadmin, you should be aware of the distinction between a language and a library.

[url=http:/civis/viewtopic.php?p=27871521#p27871521:384wmw1w said:
brendan_kearney[/url]":384wmw1w]i dont care what my attitude is or if i give people the warm and fuzzies. i am not employeed to make friends. i have a job to do and i take it seriously. if someone gives me a lot of relevant but not exactly-fitting-into-my-environment kind of information, i am going to research it. i am not going whine and escalate about impediments that are mine to overcome, but push them on someone else, as has been done to me by nearly every dev that has come to me for proxied access.

Unless you give at least some modicum amount of care what your co-workers did, you'll end up doing your job poorly.

Also, if you're going to make absolute statements about how protocols work, you, especially you because its your job as sysadmin that runs the proxies to know this, also need to be able to point the dev to the justification of those statements, in this case RFC 2817.

You need to have sufficient answer to "why?". "I know for certain" just isn't good enough, be you developer, networking person, system administrator or any other IT professional.
 
yes, the CONNECT Method is used to indicate that tunneled communications are to follow. it does nothing to indicate what protocol or communication type will be tunneled, just that something will be tunneled.

i am not sure about the proxy having to be an SSL terminiation point to be able to access the UA header. we only in the last couple of years started SSL Interception on the proxies and before that, we enforced the same 3 criteria and handled SSL traffic in the same way, without issue. it seems to me that the UA header is/should be outside the encrypted part of the conversation, whereas the Host header would be inside of it.

i agree that the forge-able UA header does not add to security, but it does seem to bring the issues around the proper use of the CONNECT Method to the surface more quickly, and for that benefit, i would keep enforcing it. above that, our policy making team wants it enforced, as they feel it does exert an additional control mechanism.

i do believe the dev use http client libraries where they can, but i think the pure Java environment they are writing code for does not allow for plug-ins or whatnot, and they may not have the option to do so. either way, i gave them a quick snippet in Apache Commons, brought in the resource that gave me that snippet and he provided a full working IRMA (???) example (file ended with a .java extension). only after a week of back and forth, escalations to upper mgmt and a stern mandate from me and the resource i brought in, did the dev actually review the example.

i do have a basic understanding of language vs library, i think. i may not be able to eloquently differentiate the two, but i think i have the basics.

i will look into the RFC you cite, and will find the verbiage that seems relevant to the discussion. now that i have a resource to review and provide to the dev, i will be able to do my job better, and that is why i posted here and asked. thank you for that.
 
Status
Not open for further replies.