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

fix: use menlo security for gsib #1937

Merged
merged 1 commit into from
Oct 21, 2024
Merged

Conversation

seaerchin
Copy link
Contributor

problem

  1. gsib access to staging site fails as gsib uses a security scan which. leasd to too many redirects

solution

  1. use menlosecurity and prepend if gsib is detected

// NOTE: Prepend the menlo link if this is on GSIB because
// GSIBs do a security scan that will fail otherwise with a TOO_MANY_REDIRECTS
// error when we access the raw link directly.
if (window.name.includes(GSIB_INDICATOR)) {

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
menlo-view.menlosecurity.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.

Copilot Autofix AI about 2 months ago

To fix the problem, we need to ensure that the check for GSIB_INDICATOR is done in a more secure manner. Instead of using a substring check, we should parse the URL and verify the host against a whitelist of allowed hosts. This will prevent any arbitrary hosts from being accepted.

  1. Parse the window.name to extract the host.
  2. Check if the host is exactly menlo-view.menlosecurity.com or any other allowed subdomains.
  3. Update the code to use this more secure check.
Suggested changeset 1
src/hooks/useStagingLink.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/hooks/useStagingLink.ts b/src/hooks/useStagingLink.ts
--- a/src/hooks/useStagingLink.ts
+++ b/src/hooks/useStagingLink.ts
@@ -6,3 +6,5 @@
   // error when we access the raw link directly.
-  if (window.name.includes(GSIB_INDICATOR)) {
+  const url = new URL(window.name);
+  const allowedHosts = ['menlo-view.menlosecurity.com'];
+  if (allowedHosts.includes(url.host)) {
     return `https://safe.menlosecurity.com/${link}`
EOF
@@ -6,3 +6,5 @@
// error when we access the raw link directly.
if (window.name.includes(GSIB_INDICATOR)) {
const url = new URL(window.name);
const allowedHosts = ['menlo-view.menlosecurity.com'];
if (allowedHosts.includes(url.host)) {
return `https://safe.menlosecurity.com/${link}`
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link

@adriangohjw adriangohjw left a comment

Choose a reason for hiding this comment

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

LGTM

@alexanderleegs alexanderleegs merged commit bfd524c into develop Oct 21, 2024
6 of 8 checks passed
@alexanderleegs alexanderleegs mentioned this pull request Oct 21, 2024
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.

3 participants