Skip to content

Commit 2280fe8

Browse files
chore: update docs and logs to be more concise on security risks (googleapis#3125)
Update docs and logs to be more clear on security risks. Related: googleapis#3113 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 8bc385d commit 2280fe8

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

.hugo/layouts/shortcodes/production-security-warning.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<div class="td-sidebar-link td-sidebar-link__page alert alert-warning shadow-sm" role="alert">
22
<h4 class="alert-heading">⚠️ Production Security Warning</h4>
3-
<p><strong>Secure your deployment:</strong> By default, Toolbox allows all hosts (<code>--allowed-hosts</code>) and all origins (<code>--allowed-origins</code>). While convenient for local development, this is <strong>insecure for production</strong>.</p>
3+
<p><strong>Secure your deployment:</strong> By default, Toolbox uses HTTP
4+
and runs on all hosts (<code>--allowed-hosts</code>) and all origins
5+
(<code>--allowed-origins</code>). While convenient, this is
6+
<strong>insecure</strong> and could expose you to unauthorized access of
7+
your toolbox instances. Please review the example under reference/cli to
8+
secure your instances.</p>
9+
10+
<p class="mt-3 mb-0 small opacity-75">Note: The server issues a warning in the logs if these are set to the wildcard <code>*</code>.</p>
411

512
<hr>
613

@@ -13,7 +20,9 @@ <h4 class="alert-heading">⚠️ Production Security Warning</h4>
1320
<strong>Implement CORS:</strong> Use the <code>--allowed-origins</code> flag to specify a list of origins permitted to access the server.
1421
<div class="mt-1"><small><em>Example:</em></small> <code>command: ["--config", "/config/tools.yaml", "--address", "0.0.0.0", "--allowed-origins", "https://foo.bar"]</code></div>
1522
</li>
23+
<li>
24+
<strong>Enable HTTPS:</strong> Use the <code>--tls-cert</code> and <code>--tls-key</code> flags to secure your connection.
25+
<div class="mt-1"><small><em>Example:</em></small> <code>command: ["--config", "/config/tools.yaml", "--address", "0.0.0.0", "--tls-cert", "cert.pem", "--tls-key", "key.pem"]</code></div>
26+
</li>
1627
</ul>
17-
18-
<p class="mt-3 mb-0 small opacity-75">Note: The server issues a warning in the logs if these are set to the wildcard <code>*</code>.</p>
1928
</div>

docs/en/documentation/deploy-to/_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ secret manager.
2323
To enable HTTPS, you must provide a valid pair of `--tls-cert` and `--tls-key`
2424
files; specifying only one will cause the server to fail at startup.
2525
{{< /notice >}}
26+
27+
{{< production-security-warning >}}

internal/server/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ func NewServer(ctx context.Context, cfg ServerConfig) (*Server, error) {
392392

393393
// cors
394394
if slices.Contains(cfg.AllowedOrigins, "*") {
395-
s.logger.WarnContext(ctx, "wildcard (`*`) allows all origin to access the resource and is not secure. Use it with cautious for public, non-sensitive data, or during local development. Recommended to use `--allowed-origins` flag")
395+
s.logger.WarnContext(ctx, "wildcard (*) allows any website to access the resources. This creates a security risk regardless of whether you are in a production or local development environment. Recommended to use --allowed-origins with specific local addresses.")
396396
}
397397
corsOpts := cors.Options{
398398
AllowedOrigins: cfg.AllowedOrigins,
@@ -405,7 +405,7 @@ func NewServer(ctx context.Context, cfg ServerConfig) (*Server, error) {
405405
r.Use(cors.Handler(corsOpts))
406406
// validate hosts for DNS rebinding attacks
407407
if slices.Contains(cfg.AllowedHosts, "*") {
408-
s.logger.WarnContext(ctx, "wildcard (`*`) allows all hosts to access the resource and is not secure. Use it with cautious for public, non-sensitive data, or during local development. Recommended to use `--allowed-hosts` flag to prevent DNS rebinding attacks")
408+
s.logger.WarnContext(ctx, "wildcard (*) hosts allow any domain to access this resource, making it vulnerable to DNS rebinding attacks regardless of whether you are in a production or local development environment. For improved security, use the --allowed-hosts flag to specify trusted domains.")
409409
}
410410
allowedHostsMap := make(map[string]struct{}, len(cfg.AllowedHosts))
411411
for _, h := range cfg.AllowedHosts {

0 commit comments

Comments
 (0)