这是indexloc提供的服务,不要输入任何密码
Skip to content

pkg/ffuf: fix panic in Windows when parsing wordlist flag #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2020

Conversation

jimen0
Copy link
Contributor

@jimen0 jimen0 commented Oct 18, 2020

Description

This change addresses two panics that happened while parsing the provided wordlist flag in Windows systems.

  • pkg/ffuf/util.go:40: panic happened when the provided path was invalid. Example: .\wordlist.txt: as the os.Stat call returned an error different than os.ErrNotExist.

  • pkg/ffuf/optionsparser.go:179: panic happened when the provided value did not existed and did not contain a colon character. Example: .\asdf.txt when the local file .\asdf.txt did not exist. This panic happened due to strings.LastIndex returning -1 when the provided substring does not appear. Therefore, v[:-1] panicking.

Fixes #333

Additonally

  • If this is the first time you are contributing to ffuf, add your name to CONTRIBUTORS.md.
    The file should be alphabetically ordered.
  • Add a short description of the fix to CHANGELOG.md

Please, test this patch thoroughly using a Windows system before merging it. I'd like to contribute unit tests for this patch too in order to avoid having a regression or incomplete fix. However, it would require a bigger refactor of the file rather than just 2 panic fixes.

Note: pkg/ffuf/optionsparser.go:181 (L185 on my patch) does not panic as strings.LastIndex returning -1 will make the slice access to be v[0:], preserving the complete vvalue. It would be nice to prevent this in a next patch, though.

@jimen0 jimen0 force-pushed the win-panic-wordlist-flag branch 2 times, most recently from da94c64 to 0833647 Compare October 18, 2020 17:03
This change addresses two panics that happened while parsing the provided
wordlist flag in Windows systems.

- pkg/ffuf/util.go:40: panic happened when the provided path was
invalid. Example: ".\wordlist.txt:" as the os.Stat call returned an
error different than os.ErrNotExist.

- pkg/ffuf/optionsparser.go:179: panic happened when the provided value
did not existed and did not contain a colon character. Example:
".\asdf.txt" when the local file ".\asdf.txt" did not exist. This panic
happened due to strings.LastIndex returning -1 when the provided
substring does not appear. Therefore, v[:-1] panicking.

Fixes ffuf#333

Signed-off-by: Miguel Ángel Jimeno <miguelangel4b@gmail.com>
@jimen0 jimen0 force-pushed the win-panic-wordlist-flag branch from 0833647 to 576ade3 Compare October 18, 2020 17:07
Copy link
Member

@joohoi joohoi left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! This looks solid.

I would just like to understand the one bit I left a comment here (it's not a change request, but I would just like to understand the scenario here).

@jimen0 jimen0 requested a review from joohoi October 22, 2020 08:15
@jimen0
Copy link
Contributor Author

jimen0 commented Oct 26, 2020

Hi @joohoi, did you have a chance to check my previous comment?

Copy link
Member

@joohoi joohoi left a comment

Choose a reason for hiding this comment

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

Yeah, thanks a lot! LGTM, merging!

@joohoi joohoi merged commit c6a6293 into ffuf:master Oct 26, 2020
@jimen0 jimen0 deleted the win-panic-wordlist-flag branch October 27, 2020 07:20
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.

panic: runtime error: slice bounds out of range [:-1]
2 participants