Skip to content

Fatal BUG in Modsecurity 2.8.0 #730

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

Closed
hemao77 opened this issue May 28, 2014 · 1 comment
Closed

Fatal BUG in Modsecurity 2.8.0 #730

hemao77 opened this issue May 28, 2014 · 1 comment

Comments

@hemao77
Copy link

hemao77 commented May 28, 2014

A fatal BUG 2.8.0.
this BUG will cause Nginx crash and can be easily reproduced.

The Root cause is located in function move_brigade_to_chain

the "next" ngx_chain_t sturcture is not initialized before use and leave in random value. this will cause crash in chunked filter module in nginx, and can be easily reproduced when deployed as reverse-proxy and chunked traffic pass thru .

patch:
ngx_int_t
move_brigade_to_chain(apr_bucket_brigade _bb, ngx_chain_t *_ll, ngx_pool_t *pool) {
apr_bucket *e;
ngx_buf_t *buf;
ngx_chain_t *cl;

cl = NULL;

if (APR_BRIGADE_EMPTY(bb)) {
    *ll = NULL;
    return NGX_OK;
}

for (e = APR_BRIGADE_FIRST(bb);
        e != APR_BRIGADE_SENTINEL(bb);
        e = APR_BUCKET_NEXT(e)) {

    if (APR_BUCKET_IS_EOS(e)) {
        if (cl == NULL) {
            cl = ngx_alloc_chain_link(pool);
            if (cl == NULL) {
                break;
            }

            cl->buf = ngx_calloc_buf(pool);
            if (cl->buf == NULL) {
                break;
            }

+++ cl->next = NULL;
cl->buf->last_buf = 1;
*ll = cl;
} else {
cl->buf->last_buf = 1;
}
apr_brigade_cleanup(bb);
return NGX_OK;
}
if (APR_BUCKET_IS_METADATA(e)) {
continue;
}

    buf = apr_bucket_to_ngx_buf(e, pool);
    if (buf == NULL) {
        break;
    }

    cl = ngx_alloc_chain_link(pool);
    if (cl == NULL) {
        break;
    }

    cl->buf = buf;
    cl->next = NULL;
    *ll = cl;
    ll = &cl->next;
}

apr_brigade_cleanup(bb);
/* no eos or error */
return NGX_ERROR;

}

@zimmerle
Copy link
Contributor

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

No branches or pull requests

2 participants