Skip to content

mod_proxy_balancer: use apr_isspace when scanning Cookie header - #675

Closed
arshsmith1 wants to merge 1 commit into
apache:trunkfrom
arshsmith1:balancer-cookie-ctype
Closed

mod_proxy_balancer: use apr_isspace when scanning Cookie header#675
arshsmith1 wants to merge 1 commit into
apache:trunkfrom
arshsmith1:balancer-cookie-ctype

Conversation

@arshsmith1

Copy link
Copy Markdown
  1. get_cookie_param() scans the client-supplied Cookie request header and passes raw char bytes (start_cookie[-1] and *start_cookie) straight to isspace().
  2. on platforms where char is signed, a cookie byte >= 0x80 reaches isspace() as a negative int, which is outside the unsigned-char / EOF domain the ctype functions are defined for, so the result is undefined.

This is reachable on any balancer with a sticky session (get_cookie_param is called from find_session_route via balancer->s->sticky), so the byte is fully attacker-controlled. Switched both calls to apr_isspace, which indexes through unsigned char and is already what the surrounding proxy/http/server code uses everywhere else.

1. get_cookie_param scans the client-supplied Cookie header and hands raw signed char bytes to isspace().
2. a cookie byte >= 0x80 reaches isspace() as a negative int, outside the unsigned char / EOF domain ctype requires, which is undefined.
Switched both calls to apr_isspace, which indexes via unsigned char like the rest of the proxy and http code.
@arshsmith1

Copy link
Copy Markdown
Author

any update?

@notroj

Copy link
Copy Markdown
Collaborator

Thanks for the PR

notroj added a commit to notroj/httpd that referenced this pull request Aug 7, 2026
* modules/proxy/mod_proxy_balancer.c (find_session_route): Replace
isspace() with apr_isspace() to avoid locale-dependent behavior
and undefined behavior with negative char values.
Submitted by: arshsmith1 <arshi bugqore.com>
GitHub: closesapache#675
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1936266 13f79535-47bb-0310-9956-ffa450edef68
notroj added a commit to notroj/httpd that referenced this pull request Aug 7, 2026
* modules/proxy/mod_proxy_balancer.c (find_session_route): Replace
isspace() with apr_isspace() to avoid locale-dependent behavior
and undefined behavior with negative char values.
Submitted by: arshsmith1 <arshi bugqore.com>
GitHub: closesapache#675
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1936266 13f79535-47bb-0310-9956-ffa450edef68
Sign up for freeto 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.

2 participants

@arshsmith1@notroj