You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Ben Noordhuis (JIRA)" <ji...@apache.org> on 2011/03/10 01:02:59 UTC
[jira] Created: (CXF-3390) Field value from previous request is
recycled when field is absent in new request
Field value from previous request is recycled when field is absent in new request
---------------------------------------------------------------------------------
Key: CXF-3390
URL: https://issues.apache.org/jira/browse/CXF-3390
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 2.4
Reporter: Ben Noordhuis
Priority: Critical
This was tested against 2.3.1 and HEAD.
Consider this class:
{code}
@Path("/test")
public class Test {
@QueryParam("q") private String q;
@GET
public void test() {
System.err.println(q);
}
}
{code}
Now consider this test case:
{noformat}
$ curl http://localhost:8080/test # prints "null"
$ curl http://localhost:8080/test?q=foo # prints "foo"
$ curl http://localhost:8080/test # prints "foo" !
{noformat}
This is a serious bug because it leaks information. It's not specific to @QueryParam, the other annotations have the same problem.
I discovered it in a resource that is used for authentication: after logging in once, I could log in again without providing a username and password!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CXF-3390) Field value from previous request is
recycled when field is absent in new request
Posted by "Ben Noordhuis (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13005171#comment-13005171 ]
Ben Noordhuis commented on CXF-3390:
------------------------------------
Thanks, Sergey!
I actually started out with prototype-scoped beans. When that didn't work I assumed I was doing something wrong and switched first to request and then thread-local scoped beans.
This is something for another issue, but field values in request-scoped (CGLIB AOP-proxied) beans are always null. Injection apparently fails but I'm not quite sure why. If I have an hour to kill, I'll try to track down the cause.
Anyway, consider this issue resolved. :-) Thanks again!
> Field value from previous request is recycled when field is absent in new request
> ---------------------------------------------------------------------------------
>
> Key: CXF-3390
> URL: https://issues.apache.org/jira/browse/CXF-3390
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.4
> Reporter: Ben Noordhuis
> Priority: Critical
>
> This was tested against 2.3.1 and HEAD.
> Consider this class:
> {code}
> @Path("/test")
> public class Test {
> @QueryParam("q") private String q;
> @GET
> public void test() {
> System.err.println(q);
> }
> }
> {code}
> Now consider this test case:
> {noformat}
> $ curl http://localhost:8080/test # prints "null"
> $ curl http://localhost:8080/test?q=foo # prints "foo"
> $ curl http://localhost:8080/test # prints "foo" !
> {noformat}
> This is a serious bug because it leaks information. It's not specific to @QueryParam, the other annotations have the same problem.
> I discovered it in a resource that is used for authentication: after logging in once, I could log in again without providing a username and password!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CXF-3390) Field value from previous request is
recycled when field is absent in new request
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13005186#comment-13005186 ]
Sergey Beryozkin commented on CXF-3390:
---------------------------------------
for the injection in CGLIB proxies to work well you might to try injecting via methods, you may want to try introducing a dedicated interface with those setters and the injection should work. Otherwise with Spring mixing all sort of proxies, the field injection probably won't work
> Field value from previous request is recycled when field is absent in new request
> ---------------------------------------------------------------------------------
>
> Key: CXF-3390
> URL: https://issues.apache.org/jira/browse/CXF-3390
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.4
> Reporter: Ben Noordhuis
> Priority: Critical
>
> This was tested against 2.3.1 and HEAD.
> Consider this class:
> {code}
> @Path("/test")
> public class Test {
> @QueryParam("q") private String q;
> @GET
> public void test() {
> System.err.println(q);
> }
> }
> {code}
> Now consider this test case:
> {noformat}
> $ curl http://localhost:8080/test # prints "null"
> $ curl http://localhost:8080/test?q=foo # prints "foo"
> $ curl http://localhost:8080/test # prints "foo" !
> {noformat}
> This is a serious bug because it leaks information. It's not specific to @QueryParam, the other annotations have the same problem.
> I discovered it in a resource that is used for authentication: after logging in once, I could log in again without providing a username and password!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CXF-3390) Field value from previous request is
recycled when field is absent in new request
Posted by "Ben Noordhuis (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004890#comment-13004890 ]
Ben Noordhuis commented on CXF-3390:
------------------------------------
This bug is caused by the null checks in JAXRSUtils.handleSetters().
Color diff and raw patch:
https://github.com/bnoordhuis/cxf/compare/CXF-3390
https://github.com/bnoordhuis/cxf/compare/CXF-3390.patch
Tests and style checks pass.
> Field value from previous request is recycled when field is absent in new request
> ---------------------------------------------------------------------------------
>
> Key: CXF-3390
> URL: https://issues.apache.org/jira/browse/CXF-3390
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.4
> Reporter: Ben Noordhuis
> Priority: Critical
>
> This was tested against 2.3.1 and HEAD.
> Consider this class:
> {code}
> @Path("/test")
> public class Test {
> @QueryParam("q") private String q;
> @GET
> public void test() {
> System.err.println(q);
> }
> }
> {code}
> Now consider this test case:
> {noformat}
> $ curl http://localhost:8080/test # prints "null"
> $ curl http://localhost:8080/test?q=foo # prints "foo"
> $ curl http://localhost:8080/test # prints "foo" !
> {noformat}
> This is a serious bug because it leaks information. It's not specific to @QueryParam, the other annotations have the same problem.
> I discovered it in a resource that is used for authentication: after logging in once, I could log in again without providing a username and password!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Resolved: (CXF-3390) Field value from previous request is
recycled when field is absent in new request
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Beryozkin resolved CXF-3390.
-----------------------------------
Resolution: Fixed
Assignee: Sergey Beryozkin
> Field value from previous request is recycled when field is absent in new request
> ---------------------------------------------------------------------------------
>
> Key: CXF-3390
> URL: https://issues.apache.org/jira/browse/CXF-3390
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.4
> Reporter: Ben Noordhuis
> Assignee: Sergey Beryozkin
> Priority: Critical
>
> This was tested against 2.3.1 and HEAD.
> Consider this class:
> {code}
> @Path("/test")
> public class Test {
> @QueryParam("q") private String q;
> @GET
> public void test() {
> System.err.println(q);
> }
> }
> {code}
> Now consider this test case:
> {noformat}
> $ curl http://localhost:8080/test # prints "null"
> $ curl http://localhost:8080/test?q=foo # prints "foo"
> $ curl http://localhost:8080/test # prints "foo" !
> {noformat}
> This is a serious bug because it leaks information. It's not specific to @QueryParam, the other annotations have the same problem.
> I discovered it in a resource that is used for authentication: after logging in once, I could log in again without providing a username and password!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CXF-3390) Field value from previous request is
recycled when field is absent in new request
Posted by "Ben Noordhuis (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13005076#comment-13005076 ]
Ben Noordhuis commented on CXF-3390:
------------------------------------
Thanks for the quick reply, Sergey.
I wouldn't expect this to work properly with true singletons but this issue also manifests itself when the resource is thread-local scoped (through a Spring AOP proxy, couldn't get CXF to wire up request-scoped beans). The resource is thread-safe, CXF can inject to its heart's desire.
> Injecting request parameters (as opposed to contexts) is thread-unsafe.
Agreed. Is there a reason why the runtime allows this? Shouldn't it complain loudly?
> Field value from previous request is recycled when field is absent in new request
> ---------------------------------------------------------------------------------
>
> Key: CXF-3390
> URL: https://issues.apache.org/jira/browse/CXF-3390
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.4
> Reporter: Ben Noordhuis
> Priority: Critical
>
> This was tested against 2.3.1 and HEAD.
> Consider this class:
> {code}
> @Path("/test")
> public class Test {
> @QueryParam("q") private String q;
> @GET
> public void test() {
> System.err.println(q);
> }
> }
> {code}
> Now consider this test case:
> {noformat}
> $ curl http://localhost:8080/test # prints "null"
> $ curl http://localhost:8080/test?q=foo # prints "foo"
> $ curl http://localhost:8080/test # prints "foo" !
> {noformat}
> This is a serious bug because it leaks information. It's not specific to @QueryParam, the other annotations have the same problem.
> I discovered it in a resource that is used for authentication: after logging in once, I could log in again without providing a username and password!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CXF-3390) Field value from previous request is
recycled when field is absent in new request
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13005145#comment-13005145 ]
Sergey Beryozkin commented on CXF-3390:
---------------------------------------
Sure - the patch makes more sense to me now, please see
http://svn.apache.org/viewvc?rev=1080267&view=rev
I'm also adding a fine/trace level logging. That is not too loud :-) but at least it can provide the hint...
By the way, re request-scoped beans, please see:
http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-FromSpring
thanks
> Field value from previous request is recycled when field is absent in new request
> ---------------------------------------------------------------------------------
>
> Key: CXF-3390
> URL: https://issues.apache.org/jira/browse/CXF-3390
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.4
> Reporter: Ben Noordhuis
> Priority: Critical
>
> This was tested against 2.3.1 and HEAD.
> Consider this class:
> {code}
> @Path("/test")
> public class Test {
> @QueryParam("q") private String q;
> @GET
> public void test() {
> System.err.println(q);
> }
> }
> {code}
> Now consider this test case:
> {noformat}
> $ curl http://localhost:8080/test # prints "null"
> $ curl http://localhost:8080/test?q=foo # prints "foo"
> $ curl http://localhost:8080/test # prints "foo" !
> {noformat}
> This is a serious bug because it leaks information. It's not specific to @QueryParam, the other annotations have the same problem.
> I discovered it in a resource that is used for authentication: after logging in once, I could log in again without providing a username and password!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CXF-3390) Field value from previous request is
recycled when field is absent in new request
Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13005006#comment-13005006 ]
Sergey Beryozkin commented on CXF-3390:
---------------------------------------
Hi Ben
I think this issue is invalid.
Injecting request parameters (as opposed to contexts) is thread-unsafe. Thus this approach only works for per-request resource classes where one can be sure the fields will be properly initialized.
I think you can just replace use
@Context UriInfo ui;
instead and have ui.getQueryParameters().getFirst("p") and it will work well. Alternatively pass the QueryParam in the method signature
> Field value from previous request is recycled when field is absent in new request
> ---------------------------------------------------------------------------------
>
> Key: CXF-3390
> URL: https://issues.apache.org/jira/browse/CXF-3390
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.4
> Reporter: Ben Noordhuis
> Priority: Critical
>
> This was tested against 2.3.1 and HEAD.
> Consider this class:
> {code}
> @Path("/test")
> public class Test {
> @QueryParam("q") private String q;
> @GET
> public void test() {
> System.err.println(q);
> }
> }
> {code}
> Now consider this test case:
> {noformat}
> $ curl http://localhost:8080/test # prints "null"
> $ curl http://localhost:8080/test?q=foo # prints "foo"
> $ curl http://localhost:8080/test # prints "foo" !
> {noformat}
> This is a serious bug because it leaks information. It's not specific to @QueryParam, the other annotations have the same problem.
> I discovered it in a resource that is used for authentication: after logging in once, I could log in again without providing a username and password!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (CXF-3390) Field value from previous request is
recycled when field is absent in new request
Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CXF-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Kulp updated CXF-3390:
-----------------------------
Fix Version/s: 2.4
> Field value from previous request is recycled when field is absent in new request
> ---------------------------------------------------------------------------------
>
> Key: CXF-3390
> URL: https://issues.apache.org/jira/browse/CXF-3390
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.4
> Reporter: Ben Noordhuis
> Assignee: Sergey Beryozkin
> Priority: Critical
> Fix For: 2.4
>
>
> This was tested against 2.3.1 and HEAD.
> Consider this class:
> {code}
> @Path("/test")
> public class Test {
> @QueryParam("q") private String q;
> @GET
> public void test() {
> System.err.println(q);
> }
> }
> {code}
> Now consider this test case:
> {noformat}
> $ curl http://localhost:8080/test # prints "null"
> $ curl http://localhost:8080/test?q=foo # prints "foo"
> $ curl http://localhost:8080/test # prints "foo" !
> {noformat}
> This is a serious bug because it leaks information. It's not specific to @QueryParam, the other annotations have the same problem.
> I discovered it in a resource that is used for authentication: after logging in once, I could log in again without providing a username and password!
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira