Skip to content

core, proxy_fcgi: Honor responsefieldsize for FCGI response headers - #522

Open
arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:64919-mod_proxy_fcgi-long-header
Open

arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:64919-mod_proxy_fcgi-long-header

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Mar 11, 2025 •

Copy link
Copy Markdown
Member

A response header line of 8190 bytes or more (name, colon and value) from a FastCGI backend fails with a 500 and "Premature end of script headers" (AH01070, AH01075). The line is read by ap_scan_script_header_err_core_ex() into a fixed buffer of MAX_STRING_LEN (8192) bytes.

Add ap_scan_script_header_err_brigade_limit(), which takes the size of the line buffer, and let mod_proxy_fcgi pass the worker's responsefieldsize, as mod_proxy_http does. The default stays 8192, so there is no change unless the option is set. A header line can be at most responsefieldsize - 3 bytes.

This limits only the size of a header line accepted by the scanner. It does not bound the memory used while the header block is received; that is pre-existing and not changed here.

Adds test/modules/proxy/test_07_fcgi.py, a changes entry, and a note in the responsefieldsize documentation.

PR: 64919

Comment thread modules/proxy/mod_proxy_fcgi.c Outdated
return 0;
}

/**

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should be added to the varbuf API in server/util.c or else the existing ap_varbuf_* should be used, IMO.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sound reasonable move it to server/util.c

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Please @notroj do another pass

Comment thread modules/proxy/mod_proxy_fcgi.c Outdated
ob = apr_brigade_create(r->pool, c->bucket_alloc);

/* Create our dynamic header buffer for large headers */
ap_varbuf *header_vb = NULL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaration should be at the top of the function, this is causing the CI failures.

@arturobernalg arturobernalg Mar 11, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix it

@arturobernalg
arturobernalg force-pushed the 64919-mod_proxy_fcgi-long-header branch 2 times, most recently from d209278 to 0eec747 Compare March 11, 2025 15:24
@arturobernalg
arturobernalg requested a review from notroj March 11, 2025 15:34
@ethan-gallant

Copy link
Copy Markdown

Hey @notroj & @arturobernalg! Wondering if there is more work needed here or if there's additional steps to take.

Happy to help out if so! :)

Comment thread modules/proxy/mod_proxy_fcgi.c Outdated
* headers, so this part of the data will need
* to persist. */
apr_bucket_setaside(b, setaside_pool);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs probably change indent for the above code...

A header line of a FastCGI response was limited to 8192 bytes, the size of
the buffer ap_scan_script_header_err_brigade_ex() reads the lines into, and
a longer one failed with "Premature end of script headers".

Add ap_scan_script_header_err_brigade_limit() to read the lines into a
buffer of a given size. The existing brigade functions use it with
MAX_STRING_LEN, so they do not change. mod_proxy_fcgi passes it the
responsefieldsize of the worker, as mod_proxy_http does, which is 8192 by
default. It limits the size of a header line the scanner accepts.

PR: 64919
@arturobernalg
arturobernalg force-pushed the 64919-mod_proxy_fcgi-long-header branch from 0eec747 to 8956a77 Compare October 15, 2026 11:21
@arturobernalg arturobernalg changed the title mod_proxy_fcgi: Support Dynamic Buffering for Large FastCGI Headers core, proxy_fcgi: Honor responsefieldsize for FCGI response headers Oct 15, 2026
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.

4 participants