Repository navigation
mod_vhost_alias: reserve a byte for the terminating NUL in checkspace - #833
Open
arshsmith1 wants to merge 1 commit into
Open
arshsmith1 wants to merge 1 commit into
arshsmith1 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following up on the recent "harden vhost_alias" change, there is still a one-byte stack overflow left in the same path.
vhost_alias_interpolate()builds the interpolated VirtualDocumentRoot/VirtualScriptAlias path into a fixedchar buf[HUGE_STRING_LEN], andvhost_alias_checkspace()only flushes/resetsdestwhen*pdest + size > buf + HUGE_STRING_LEN. A write that ends exactly atbuf + HUGE_STRING_LENis therefore allowed, leavingdestone byte past the end ofbuf.**pdest = '\0'and the terminating*dest = '\0'at the end of the function then write that NUL one byte pastbuf.The size of a
%Nsegment comes from the server name (the Host header), so with an ordinary config such asVirtualDocumentRoot /var/www/%0a request whose Host length makes the accumulated output total exactlyHUGE_STRING_LENreaches the boundary and writes past the buffer. ASAN reports it as a stack-buffer-overflow WRITE of size 1; on a normal build it is a single stray NUL into adjacent stack, so it is only cleanly observable under ASAN and exists on trunk after the recent hardening (hence a normal bug fix per SECURITY.md, not the vulnerability process).The fix reserves one byte for the terminator by flushing when
*pdest + size >= buf + HUGE_STRING_LEN. Output is byte-identical for every in-bounds expansion; only the exact-fill case now flushes one segment earlier instead of running over.There is no
test/modules/mappershome for a pyhttpd test and the single-byte overrun is not observable on a normal (non-ASAN) build, so no functional test is included, matching the shape of the original hardening commit. I verified the overflow and the fix with a standalone ASAN harness over the extracted buffer logic and can share it if useful.(see
SECURITY.mdandhttps://www.apache.org/security/#reporting-a-vulnerability).
APLOGNO()tag;numbers are assigned by a committer at merge time (see
docs/log-message-tags/README).changes-entries/*.txtfile is included,following the template in
README.CHANGES(not needed otherwise).test/modules/xxxdirectory matching themodules/xxxmodule source,or
test/modules/corefor core server changes. On Unix, verify thesepass locally with e.g.
make check-pytest PYTEST_DIRS=test/modules/xxx.AI tooling was used to help prepare this change.