Repository navigation
Conversation
-noslash strips a trailing slash so '/admin/' is requested as '/admin'. Applied as a bare s/\/$// it also turns the root path '/' into an empty string. That empty URI normally survives only because http_fixup_request() rewrites it back to '/', but that fixup is skipped on the 'noclean' request path, which would leave a malformed request line. Use a lookbehind so the slash is removed only when another character precedes it: '/' is left untouched while '/admin/' still becomes '/admin'.
|
Did you find that by debugging it after something went wrong or were you
looking for problems?
…On Sun, 4 Oct 2026, 17:58 Mr.X, ***@***.***> wrote:
Summary
-noslash is documented as stripping a trailing slash, e.g. /admin/ →
/admin. The implementation used a bare s/\/$//, which also turns the root
path / into an empty string.
# program/plugins/nikto_core.plugin$request{'whisker'}->{'uri'} =~ s/\/$// if ($CLI{'noslash'});
For a request to /, the URI becomes "". That empty URI normally survives
only because LW2::http_fixup_request() rewrites an empty URI back to / —
but that fixup is skipped on the noclean request path (...http_fixup_request(\%request)
unless ($flags->{'noclean'})), which would leave a malformed request line.
Fix
Use a lookbehind so the trailing slash is removed only when another
character precedes it. / is left untouched; /admin/ still becomes /admin.
$request{'whisker'}->{'uri'} =~ s{(?<=.)/$}{} if ($CLI{'noslash'});
Verification
$ perl -e 'for my $u ("/", "/admin/", "/a/b/", "//", "/foo", "") {
(my $old = $u) =~ s/\/$//;
(my $new = $u) =~ s{(?<=.)/$}{};
printf "%-10s old=%-8s new=%-8s\n", $u, "\x27$old\x27", "\x27$new\x27"; }'
/ old='' new='/'
/admin/ old='/admin' new='/admin'
/a/b/ old='/a/b' new='/a/b'
// old='/' new='/'
/foo old='/foo' new='/foo'
old='' new=''
$ perl -c program/plugins/nikto_core.plugin
program/plugins/nikto_core.plugin syntax OK
$ cd program && perl nikto.pl -dbcheck -nolookup # core loads/runs clean
------------------------------
You can view, comment on, or merge this pull request online at:
#916
Commit Summary
- ce49f32
<ce49f32>
Preserve root path when stripping trailing slash for -noslash
File Changes
(1 file <https://github.com/sullo/nikto/pull/916/files>)
- *M* program/plugins/nikto_core.plugin
<https://github.com/sullo/nikto/pull/916/files#diff-0dfffae278774b7d83fb0f8df0815860e21f079cf9f16c2c565cf317612b47b6>
(7)
Patch Links:
- https://github.com/sullo/nikto/pull/916.patch
- https://github.com/sullo/nikto/pull/916.diff
—
Reply to this email directly, view it on GitHub
<#916?email_source=notifications&email_token=AAA4SWMAQS3SAGNATR3EX5D5SJ6VDA5CNFSNUABEM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UF42DOMZWGA3DKOBUGCTHEZLBONXW5KTTOVRHGY3SNFRGKZFFMV3GK3TUVRTG633UMVZF6Y3MNFRWW>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA4SWP6Y3KEJEV2PUYWVQ35SJ6VDAVCNFSNUABDKJSXA33TNF2G64TZHM3DQMZWGI4TSO2JONZXKZJ3GU3TAMJTHA2TSMBUUF3AE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
@sullo when you get a chance, this is a small one-line fix: |
|
honestly just spotted it reading through the code, wasn't chasing a crash or anything. |
|
It looks good to me, but it's up to Sullo not me too decide.
…On Sun, 4 Oct 2026, 20:16 Mr.X, ***@***.***> wrote:
*MRX-72* left a comment (sullo/nikto#916)
<#916 (comment)>
honestly just spotted it reading through the code, wasn't chasing a crash
or anything. -noslash ends up turning / into an empty string which kind
of defeats the point of the option. most of the time you won't notice
because http_fixup_request resets empty back to /, but that bit gets
skipped on the noclean path so it can leak through there. felt like a cheap
one liner to fix so figured why not. no worries if you reckon it's too edge
casey, happy to close it.
—
Reply to this email directly, view it on GitHub
<#916?email_source=notifications&email_token=AAA4SWMDHT7RSROR2J3MXTL5SKOXLA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKOJYGM2DMOBSGQ32M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5983468247>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA4SWI2PE22VNBTXDLIFED5SKOXLAVCNFSNUABDKJSXA33TNF2G64TZHM3DQMZWGI4TSO2JONZXKZJ3GU3TAMJTHA2TSMBUUF3AE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
Good catch, thanks for reporting/fixing. I've merged it into pre-release as 2b17abe and will get out in the next release which is 1-2 weeks out. |
Summary
-noslashis documented as stripping a trailing slash, e.g./admin/→/admin. The implementation used a bares/\/$//, which also turns the root path/into an empty string.For a request to
/, the URI becomes"". That empty URI normally survives only becauseLW2::http_fixup_request()rewrites an empty URI back to/— but that fixup is skipped on thenocleanrequest path (...http_fixup_request(\%request) unless ($flags->{'noclean'})), which would leave a malformed request line.Fix
Use a lookbehind so the trailing slash is removed only when another character precedes it.
/is left untouched;/admin/still becomes/admin.Verification