akto-api-security / akto

Proactive, Open source API security ā†’ API discovery, Testing in CI/CD, Test Library with 150+ Tests, Add custom tests, Sensitive data exposure
https://www.akto.io/
MIT License
983 stars 191 forks source link

ā›ļø Write test for fetching data using SFTP, DICT, GOPHER, LDAP, TFTP protocols via SSRF #137

Closed aktoboy closed 10 months ago

aktoboy commented 1 year ago

šŸ’­ Introduction: We want to test whether API's which take in url as a param are vulnerable to fetch information via protocols like SFTP, DICT, GOPHER, LDAP, TFTP using SSRF. You can refer this blog for more details about the attack.

šŸŽÆ Requirements: This test should only run for APIs which are taking url as a parameter in input. The test should cover the protocols mentioned in Introduction section. An SSRF example is implemented here already.

šŸ“š Reading You can find a detailed documentation of test editor rules here Find 100+ examples of YAML tests here

āœ… Task summary:

āœŒšŸ» Hints: You can build the yaml template by referring this link

šŸ™‹šŸ¼ā€ā™‚ļø Questions: If you have questions, need any help, or just want to hang out, make sure to join us on our Discord server.

adripo commented 10 months ago

I would like to attempt to solve this issue. Can I be assigned please?

avneesh-akto commented 10 months ago

Done

adripo commented 10 months ago

I am not able to validate the response through tests so I assume that a 2xx answer is enough for validation.

avneesh-akto commented 10 months ago

No @adripo. Just validating 2xx response code will lead to lot of false positives. Try to add more validation

adripo commented 10 months ago

@avneesh-akto I added some payloads and headers for the validation

adripo commented 10 months ago

@avneesh-akto can you have a look at my PR please? thanks

avneesh-akto commented 10 months ago

Hi @adripo. Your test looks good. Only issue is with test validation. contains_either doesn't support regex. So .* won't work

adripo commented 10 months ago

Thanks for the input @avneesh-akto What should I use instead of contains_either? I used regex following the docs here: https://docs.akto.io/test-editor/test-yaml-syntax-detailed/api-selection-filters#regex

avneesh-akto commented 10 months ago

Just use contains_either without regex

adripo commented 10 months ago

@avneesh-akto done. It should work correctly now. Could you also please tag the PR as hacktoberfest-accepted before October 31? Thank you

avneesh-akto commented 10 months ago

Hey your PR LGTM šŸš€ . Thank you for your submission. Please change base branch to develop.

adripo commented 10 months ago

If I rebase to develop it will keep all the commits not synced between them. I should create a new branch and cherry-pick my commits. Does this sounds good to you?

ankush-jain-akto commented 10 months ago

Hi @adripo - ~that sounds good. Please create a new PR~

Time was running out for Hacktoerfest. I simply created a new branch from master called hacktoberfest. I have merged your PR there. We will take care of merging hacktoberfest to master.

adripo commented 10 months ago

Thank you @ankush-jain-akto ! This is really nice of you.