You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2024/10/18 11:31:54 UTC
[Bug 69404] New: htdbm poor user check leading to NullDereference
https://bz.apache.org/bugzilla/show_bug.cgi?id=69404
Bug ID: 69404
Summary: htdbm poor user check leading to NullDereference
Product: Apache httpd-2
Version: 2.5-HEAD
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: support
Assignee: bugs@httpd.apache.org
Reporter: anasonov@astralinux.ru
Target Milestone: ---
Created attachment 39912
--> https://bz.apache.org/bugzilla/attachment.cgi?id=39912&action=edit
htdbm failure test cases with stack traces
htdbm sagfaults with specific parametrs.
Steps to reproduce:
1. Built with:
$ export CC="clang-17"
$ export CXX="clang++-17"
$ export CFLAGS="-pipe -g -O2 -fstack-protector-strong -Wformat
-Werror=format-security -fsanitize=address,undefined"
$ export UBSAN_OPTIONS=print_stacktrace=1
$ svn co http://svn.apache.org/repos/asf/apr/apr/trunk srclib/apr
$ <some buildconf calls>
$ ./configure --with-included-apr --host=x86_64-linux-gnu
--build=x86_64-linux-gnu --enable-layout=Debian --enable-so
--with-program-name=apache2 --enable-suexec --with-suexec-caller=www-data
--with-suexec-bin=/usr/lib/apache2/suexec --with-suexec-docroot=/var/www
--with-suexec-userdir=public_html
--with-suexec-logfile=/var/log/apache2/suexec.log --with-suexec-uidmin=100
--enable-suexec=shared --enable-log-config=static
--with-pcre=/usr/bin/pcre2-config --enable-pie
--enable-mpms-shared=all --with-mpm=prefork --enable-mods-shared="all brotli
cgi ident authnz_fcgi imagemap cern_meta proxy_fdpass proxy_http2 bucketeer
case_filter case_filter_in" --enable-mods-static="unixd logio watchdog version"
$ make
2. Find all testcases in attachment (with stacktraces).
Option -l sets variable need_user = 0, since then we don't call
htdbm_valid_username to check if we have a correct username in struct htdbm_t
*h. This leads to NullDereference bugs in different functions.
In my opinion, we should somehow patch this thing.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69404] htdbm poor user check leading to NullDereference
Posted by "bugzilla.apache.org via bugs" <bu...@httpd.apache.org>.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69404
--- Comment #3 from abernal <ab...@apache.org> ---
Fixed in trunk: e3d134d982 (PR #912 merged).
2.4.x backport: https://github.com/apache/httpd/pull/1051
Clean cherry-pick. On a 2.4.x build the new test fails without the fix ("htdbm
-n -v user" exits with SIGSEGV) and passes with it.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69404] htdbm poor user check leading to NullDereference
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69404
Artem Nasonov <an...@astralinux.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |major
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69404] htdbm poor user check leading to NullDereference
Posted by "bugzilla.apache.org via bugs" <bu...@httpd.apache.org>.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69404
--- Comment #2 from abernal <ab...@apache.org> ---
Follow-up: revised PR #912 after review caught two residual bugs in the first
version (which only patched the three helper functions with NULL guards): "-n
-l" silently exited 0 having done nothing, and "-l -x" against an existing
database printed "Cannot find user '(null)' in database" (NULL passed to
fprintf("%s")). Fixed by moving the validation to main(), right after option
parsing, rejecting these combinations with a usage error before any database
I/O or password prompt - the same layer malformed argument counts are already
rejected at. Verified with an exhaustive sanitizer sweep across the
option/argument space, and confirmed a rejected combination never touches an
already-populated database.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69404] htdbm poor user check leading to NullDereference
Posted by "bugzilla.apache.org via bugs" <bu...@httpd.apache.org>.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69404
--- Comment #1 from abernal <ab...@apache.org> ---
PR against trunk: https://github.com/apache/httpd/pull/912
Confirmed the root cause for all five crashes in the attachment: "-l" (list)
leaves username NULL (it doesn't need one) and htdbm_del() dereferenced it
unconditionally via strlen(), so "-l -x" crashed; and "-n" (print the hash, no
database file) never opens htdbm->dbm, so combining it with "-v"/"-x"/"-l"
crashed inside apr_dbm_exists()/apr_dbm_firstkey(). Reproduced with a plain
build (stock SIGSEGV, no sanitizer needed). Fix adds the username==NULL guard
htdbm_verify() already had to htdbm_del() too, plus a dbm==NULL guard in all
three functions. Verified RED (crashes on current trunk) and GREEN (fixed) with
the exact repro commands from your attachment, plus a normal
create/verify/list/delete cycle still works unchanged.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 69404] htdbm poor user check leading to NullDereference
Posted by "bugzilla.apache.org via bugs" <bu...@httpd.apache.org>.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69404
abernal <ab...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #4 from abernal <ab...@apache.org> ---
Backported to 2.4.x:
https://github.com/apache/httpd/commit/52eb24f9f620dc8be686109274e64aaee8eb8bd6
(PR #1051). Trunk: e3d134d982.
Will be in the next 2.4 release. Thanks for the report and the test cases.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org