Skip to content

Commit

Permalink
Merge branch 'master' into anilm3/sql-negative-numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Anilm3 authored Nov 19, 2024
2 parents 90c7922 + 5dc5061 commit e206ff0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/condition/ssrf_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,13 @@ ssrf_result ssrf_impl(const uri_decomposed &uri, const ddwaf_object &params,
}
}

// If the injection includes the scheme check if it's still a valid one
// If the injection includes the scheme and beyond, check if the
// potentially injected scheme is still a valid one
//
// scheme://userinfo@host:port/path?query#fragment
// ───────────────────>
if (param_index == 0 && !authorised_scheme_set.contains(uri.scheme)) {
// ───────>
if (!uri.scheme.empty() && param_index == 0 && param.size() > uri.scheme.size() &&
!authorised_scheme_set.contains(uri.scheme)) {
return {{std::string(param), it.get_current_path()}};
}

Expand Down
2 changes: 1 addition & 1 deletion src/condition/ssrf_detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace ddwaf {

class ssrf_detector : public base_impl<ssrf_detector> {
public:
static constexpr unsigned version = 1;
static constexpr unsigned version = 2;
static constexpr std::array<std::string_view, 2> param_names{"resource", "params"};

explicit ssrf_detector(std::vector<condition_parameter> args, const object_limits &limits = {});
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/condition/ssrf_detector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void match_path_and_input(
TEST(TestSSRFDetector, MatchScheme)
{
match_path_and_input({
{"gopher://blabla.com/path", {.yaml = "gopher"}},
{"gopher://blabla.com/path", {.yaml = R"("gopher:")", .resolved = "gopher:"}},
{"data://blabla.com/path",
{.yaml = R"(data://blabla.com)", .resolved = "data://blabla.com"}},
});
}

Expand Down Expand Up @@ -208,6 +210,8 @@ TEST(TestSSRFDetector, NoMatchPotentialFalsePositives)
{"http://google.com/batch", {.yaml = R"({query: {param: "batch"}})"}},
{"http://google.com/batch", {.yaml = R"({query: {param: "/batch"}})"}},
{"file/blabla/metadata", {.yaml = R"({query: {param: "blabla"}})"}},
{"gopher://blabla.com/path", {.yaml = "gopher"}},
{"data://blabla.com/path", {.yaml = "data"}},
/* {"http://scrapper-proxy.awsregion.bla.iohttps://images.bla.com/whatever",*/
/*{.yaml = R"({url: "https://images.bla.com/whatever"})"}},*/
},
Expand Down

0 comments on commit e206ff0

Please sign in to comment.