Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

fix(addFrameOptions): strict csp domain now matches #704

Merged
merged 1 commit into from
Mar 24, 2022

Conversation

JAdshead
Copy link
Contributor

@JAdshead JAdshead commented Mar 23, 2022

Description

remove "https://" from referrer when looking for frame-ancestors match

Motivation and Context

fix

How Has This Been Tested?

test suide

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update
  • Security update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • These changes should be applied to a maintenance branch.
  • This change requires cross browser checks.
  • Performance tests should be ran against the server prior to merging.
  • This change impacts caching for client browsers.
  • This change impacts HTTP headers.
  • This change adds additional environment variable requirements for One App users.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using One App?

@10xLaCroixDrinker
Copy link
Member

why is this needed?

@github-actions
Copy link
Contributor

Warnings
⚠️

Changes were made to package-lock.json, but not to package.json - Are you reverting package-lock to the npm v5 format?

📊 Bundle Size Report

file name size on disk gzip
app.js 314.2KB 93.2KB
runtime.js 15.6KB 5.5KB
vendors.js 148.4KB 47.5KB
app~vendors.js 431KB 111.8KB
service-worker-client.js 17.1KB 5.3KB
legacy/app.js 334.8KB 98KB
legacy/runtime.js 15.6KB 5.5KB
legacy/vendors.js 208.6KB 59.4KB
legacy/app~vendors.js 452.7KB 117.5KB
legacy/service-worker-client.js 17.6KB 5.5KB

Generated by 🚫 dangerJS against e9d9392

@@ -6,7 +6,7 @@
"packages": {
"": {
"name": "@americanexpress/one-app",
"version": "5.13.0",
"version": "5.13.1",
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its changed to match the actual current version.

@@ -21,8 +21,8 @@ export default function addFrameOptionsHeader(req, res, next) {
const referer = req.get('Referer');

const frameAncestorDomains = getCSP()['frame-ancestors'];

const matchedDomain = frameAncestorDomains && frameAncestorDomains.find((domain) => matcher.isMatch(referer, `${domain}/*`)
const trimmedReferrer = referer && referer.replace('https://', '');
Copy link
Member

Choose a reason for hiding this comment

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

Why was https:// causing issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because if the referrer is https://some.domain.com it will always fail to match against some.domain.com . i think it is safer to strip https:// instead of putting a wildcard in front of the csp domain.

@Matthew-Mallimo Matthew-Mallimo requested a review from a team March 23, 2022 19:53
@@ -18,7 +18,7 @@ import addFrameOptionsHeader from '../../../src/server/middleware/addFrameOption

jest.mock('../../../src/server/middleware/csp', () => ({
getCSP: () => ({
'frame-ancestors': ['*.example.com'],
'frame-ancestors': ['valid.example.com'],
Copy link
Member

Choose a reason for hiding this comment

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

How will these tests protect against regression?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was the previously failing scenario.

@JAdshead
Copy link
Contributor Author

why is this needed?

Because only * domains from the CSP frame-ancestors were being added to the frame options header which results in weaker security.

@10xLaCroixDrinker 10xLaCroixDrinker merged commit ee252db into main Mar 24, 2022
@10xLaCroixDrinker 10xLaCroixDrinker deleted the fix/x-frame-options branch March 24, 2022 22:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants