Colm O hEigeartaigh created CXF-9280:
----------------------------------------

             Summary: Disable the _type and _ctype query overrides by default
                 Key: CXF-9280
                 URL: https://issues.apache.org/jira/browse/CXF-9280
             Project: CXF
          Issue Type: Improvement
            Reporter: Colm O hEigeartaigh
            Assignee: Colm O hEigeartaigh
             Fix For: 4.3.0


## Summary

Change the default of the `org.apache.cxf.jaxrs.allow.query.type.override` 
contextual property from `true` to `false` in 4.3.0, so that the `_ctype` and 
`_type` query parameters no longer override the request `Content-Type` and 
`Accept` headers unless explicitly enabled.

## Background

`RequestPreprocessor` lets clients override request headers with query 
parameters:

- `?_ctype=...` replaces the request `Content-Type` (e.g. `_ctype=json` → 
`application/json`)
- `?_type=...` replaces the `Accept` header (e.g. `_type=xml` → 
`application/xml`)

Until 4.2.x this was always enabled. The 
`org.apache.cxf.jaxrs.allow.query.type.override` property was added in 4.2.x so 
that integrators can disable it, but it defaults to `true` to preserve 
behaviour.

## Problem

`_ctype` lets a cross-site request change how the body is parsed. A malicious 
web page can make a user's browser send a "simple" cross-site form POST (e.g. 
`Content-Type: text/plain`), which does not trigger a CORS preflight. By adding 
`?_ctype=json` (or `xml`) to the URL, the body is then processed as JSON or XML.

This bypasses a common CSRF defence (only accepting `application/json` request 
bodies, which forces a preflight for cross-site requests), as well as gateways 
or filters that allow or block requests based on `Content-Type`.

`_type` only affects the response format and is lower risk, but it is 
controlled by the same property.

The related `_method` / `X-HTTP-Method-Override` override 
(`org.apache.cxf.jaxrs.allow.http.method.override`) already defaults to `false` 
for similar reasons.

## Proposed change

- Default `org.apache.cxf.jaxrs.allow.query.type.override` to `false` in 
`RequestPreprocessor`.
- Update tests that rely on `_type` / `_ctype` to enable the property 
explicitly, e.g.:
  - `RequestPreprocessorTest`
  - `JAXRSClientServerSpringBookTest`
  - `JAXRSClientServerProxySpringBookTest`
  - `JAXRSClientServerResourceCreatedSpringProviderTest`
- Document the change in the 4.3.0 migration guide.

## Migration

Applications that rely on `_type` or `_ctype` can restore the previous 
behaviour per endpoint:

<jaxrs:properties>
    <entry key="org.apache.cxf.jaxrs.allow.query.type.override" value="true"/>
</jaxrs:properties>



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to