Skip to content
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

chore: warn log when sending requests to external services insecurely #11403

Merged
merged 15 commits into from
Jul 24, 2024

Conversation

shreemaan-abhishek
Copy link
Contributor

@shreemaan-abhishek shreemaan-abhishek commented Jul 13, 2024

Description

Enforcing TLS is important when using third party services.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

moonming
moonming previously approved these changes Jul 15, 2024
Revolyssup
Revolyssup previously approved these changes Jul 15, 2024
@@ -49,6 +49,8 @@ local _M = {
}

function _M.check_schema(conf)
local check = {"idp_uri"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should cas_callback_uri and logout_uri be listed as checks? Similar fields in authz-casdoor and authz-keycloak are listed as checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cas_callback_uri and logout_uri are in the form of "/foo/bar" so we don't need to check them.

@@ -78,6 +78,8 @@ local _M = {


function _M.check_schema(conf)
local check = {"uri"}
Copy link
Contributor

Choose a reason for hiding this comment

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

The ssl_verify should also be checked, TLS without server certificate validation is meaningless.

@@ -124,6 +124,8 @@ function _M.check_schema(conf, schema_type)
if schema_type == core.schema.TYPE_METADATA then
return core.schema.check(metadata_schema, conf)
end
local check = {"endpoint_addrs"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Also check ssl_verify.

@@ -89,6 +89,8 @@ function _M.check_schema(conf, schema_type)
if schema_type == core.schema.TYPE_METADATA then
return core.schema.check(metadata_schema, conf)
end
local check = {"endpoint_addrs"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Also check ssl_verify.

@@ -114,6 +114,9 @@ local _M = {


function _M.check_schema(conf)
local check = {"discovery", "token_endpoint", "resource_registration_endpoint",
Copy link
Contributor

Choose a reason for hiding this comment

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

Also check ssl_verify.

@@ -125,6 +125,8 @@ function _M.check_schema(conf, schema_type)
return core.schema.check(metadata_schema, conf)
end

local check = {"endpoint_addrs"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Also check ssl_verify.

@@ -65,6 +65,8 @@ local _M = {


function _M.check_schema(conf)
local check = {"host"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Also check ssl_verify.

@@ -305,6 +305,10 @@ function _M.check_schema(conf)
}
end

local check = {"discovery", "introspection_endpoint", "redirect_uri",
"post_logout_redirect_uri", "proxy_opts.http_proxy"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Also check ssl_verify and proxy_opts.https_proxy.

@@ -63,6 +63,9 @@ local _M = {


function _M.check_schema(conf)
local check = {"api_host"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Also check ssl_verify.

@@ -105,10 +105,43 @@ __DATA__
}
--- response_body
done
--- error_log
Copy link
Contributor

Choose a reason for hiding this comment

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

Should tests about these warnings use a sperate test file instead of putting them in each plugin's own tests.
i.e. create a new test file that specifically tests for security risk warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it would be nice to have but there are 20+ files that would need update, very tedious job and not worth the effort IMHO.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, if such is better (for reasons of complexity of modification now and on long term maintainability) and there is no such file now, we can create such a file and place the tests in one place.

Do you think this has advantages for long term maintenance? The problem I can imagine is that plugin contributors need to know that their tests need to be written in multiple test files to test different parts. This requires either contributor knowledge or a careful reviewer.

If so, let's move those tests to a new file.

and cc @moonming @membphis for advice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on long term maintainability

I agree with you on this. 🙏🏼

@bzp2010 bzp2010 self-requested a review July 18, 2024 06:45
Copy link
Contributor

@bzp2010 bzp2010 left a comment

Choose a reason for hiding this comment

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

LGTM, only the API style and testing files are still in question.

Comment on lines 119 to 120
core.utils.check_https(check, conf, plugin_name)
core.utils.check_tls_bool({conf.ssl_verify}, {"ssl_verify"}, plugin_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just simply curious, why is the style of the two check functions so inconsistent? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean check and conf seem to be reversed. And it seems that check_tls_bool can continue to use the string pattern in check_https to get data in conf instead of supplying it upfront in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great catch 🙏🏼 , thanks for your detailed attention.

@@ -105,10 +105,43 @@ __DATA__
}
--- response_body
done
--- error_log
Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, if such is better (for reasons of complexity of modification now and on long term maintainability) and there is no such file now, we can create such a file and place the tests in one place.

Do you think this has advantages for long term maintenance? The problem I can imagine is that plugin contributors need to know that their tests need to be written in multiple test files to test different parts. This requires either contributor knowledge or a careful reviewer.

If so, let's move those tests to a new file.

and cc @moonming @membphis for advice

@moonming moonming merged commit 36b2b83 into apache:master Jul 24, 2024
35 checks passed
@shreemaan-abhishek shreemaan-abhishek deleted the security-warning branch July 24, 2024 05:26
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.

4 participants