Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added "empy chunk" check #1446

Closed
wants to merge 1 commit into from

Conversation

gravagli
Copy link

@gravagli gravagli commented Jun 6, 2017

Environment:

  • Apache 2.2.15 on CentOS 6,
  • Mod_security 2.9.1
  • SecRequestBodyAccess On
  • ProxyPass

Scope:
Apache receives SOAP requests and then proxies them to a target server. In the meantime Mod_security logs the entire request and response sequentially, thanks to SecRequestBodyAccess.

Issue:
If the client sends a chunked request big enough to force Mod_security to store the chunks on disk (more than 128 kB by default), the webserver generates two final chunk with zero instead of one.
The destination server behave like it received two requests, but the second one is sintactically uncorrected because it contains only an empty chunk.
This issue happens only when flag SecRequestBodyAccess is on, but I would like keep it enabled.
I tried to upgrade Apache to version 2.4, CentOS to version 7 but nothing changed.

Possible fix:
I checked out the code and I found the way to fix the problem:

In apache2_io.c at line 88 one more "if" is needed to prevent Mod_security to add an empty chunk in excess

if (chunk->length > 0){
      if (chunk && (!msr->txcfg->stream_inbody_inspection || (msr->txcfg->stream_inbody_inspection && msr->if_stream_changed == 0))) {
          /* Copy the data we received in the chunk */
          .....
      } else if (msr->stream_input_data != NULL) {
         .....
      }
}

I applied this fix in master, v2.9.1 tag and v2/master and it always worked out.

I ran all tests after my fix, and none failed.

@zimmerle zimmerle self-assigned this Oct 5, 2017
zimmerle pushed a commit that referenced this pull request Oct 5, 2017
@zimmerle zimmerle self-requested a review October 5, 2017 14:29
@zimmerle
Copy link
Contributor

zimmerle commented Oct 5, 2017

Merged! Thanks ;)

@zimmerle zimmerle closed this Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants