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

harden web security #259

Merged
merged 40 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ce22b0f
adds next-secure-headers
abhinavkgrd Nov 30, 2021
ec699c1
added clouflare headers config file
abhinavkgrd Dec 1, 2021
45911eb
test
abhinavkgrd Dec 1, 2021
bfd8695
update csp to report only and add report URI
abhinavkgrd Dec 1, 2021
d297b82
fix csp self value , by adding quotes
abhinavkgrd Dec 1, 2021
4580470
changed object src to none
abhinavkgrd Dec 2, 2021
366a283
move csp to meta tag in document to add inline script hash
abhinavkgrd Dec 2, 2021
87f3f7a
add Referrer-Policy header
abhinavkgrd Dec 2, 2021
e023474
remove headers as its not passed to exported app
abhinavkgrd Dec 2, 2021
d51335b
better formatted csp
abhinavkgrd Dec 2, 2021
d88e64b
add mode block to xss protection
abhinavkgrd Dec 2, 2021
25ef3a8
make content security active
abhinavkgrd Dec 2, 2021
14094d1
added unsafe inline as fallback to hash for script-src
abhinavkgrd Dec 2, 2021
4b03205
move all directive except script-src to header
abhinavkgrd Dec 2, 2021
a8ad8b2
add missing report to and reporturi to
abhinavkgrd Dec 2, 2021
e5b9ad7
remove script hash
abhinavkgrd Dec 2, 2021
e7bed74
fix report-uri
abhinavkgrd Dec 2, 2021
7969d20
test
abhinavkgrd Dec 2, 2021
59b3745
add unsafe inline to style-src
abhinavkgrd Dec 2, 2021
8ce1ae7
add back next-secure-header for local use
abhinavkgrd Dec 2, 2021
5854a94
added testing headers
abhinavkgrd Dec 2, 2021
5931bf8
add data: protocol for connect-src and remove require trusted for script
abhinavkgrd Dec 3, 2021
949dd07
activate content scurity policy
abhinavkgrd Dec 3, 2021
5df9212
add unsafe eval to allow heif.js new Function() call
abhinavkgrd Dec 3, 2021
e2e47d7
add sub-resource integrity
abhinavkgrd Dec 3, 2021
28dd87b
add html webpack plugin
abhinavkgrd Dec 3, 2021
82a15ef
run only for non server webpack
abhinavkgrd Dec 3, 2021
f9c91cd
dont need HtmlWebpackPlugin and force enable SubresourceIntegrityPlugin
abhinavkgrd Dec 3, 2021
0613209
remove unneccesary changes
abhinavkgrd Dec 3, 2021
20d6574
remove unneccasry packages
abhinavkgrd Dec 3, 2021
7df09a1
cleanup
abhinavkgrd Dec 3, 2021
7b739ae
add suggested observatory header
abhinavkgrd Dec 3, 2021
6e62f31
update to use ente domain url for workes instead of worker.dev cf dom…
abhinavkgrd Dec 20, 2021
52f0ac0
update csp report URL
abhinavkgrd Jan 3, 2022
9acb767
fix sentry tunnel URL
abhinavkgrd Jan 3, 2022
9c0f123
allow blob foir connect-src
abhinavkgrd Jan 3, 2022
09e4f89
allow blob for script src
abhinavkgrd Jan 3, 2022
db3820a
add b2 upload URL domain to connect-src
abhinavkgrd Jan 3, 2022
b789e62
fix b2 domain for connect-src
abhinavkgrd Jan 4, 2022
72ed18f
change csp to report only for deployment
abhinavkgrd Jan 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@ const gitSha = cp.execSync('git rev-parse --short HEAD', {
encoding: 'utf8',
});

// eslint-disable-next-line camelcase
const COOP_COEP_Headers = [
{
key: 'Cross-Origin-Opener-Policy',
value: 'same-origin',
},
{
key: 'Cross-Origin-Embedder-Policy',
value: 'require-corp',
},
];

module.exports = withSentryConfig(
withWorkbox(
withBundleAnalyzer({
Expand All @@ -33,17 +21,6 @@ module.exports = withSentryConfig(
swSrc: 'src/serviceWorker.js',
exclude: [/manifest\.json$/i],
},

// added to enabled shared Array buffer - https://web.dev/coop-coep/
headers() {
return [
{
// Apply these headers to all routes in your application....
source: '/(.*)',
headers: COOP_COEP_Headers,
},
];
},
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
webpack: (config, { isServer }) => {
if (!isServer) {
Expand Down
12 changes: 12 additions & 0 deletions public/_headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Cache-Control: no-store, must-revalidate
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Strict-Transport-Security: max-age=63072000
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
Referrer-Policy: same-origin
Content-Security-Policy-Report-Only: default-src 'none'; img-src 'self' blob:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self' 'unsafe-eval' blob:; connect-src 'self' https://*.ente.io data: blob: https://ente-prod-eu.s3.eu-central-003.backblazeb2.com ; base-uri 'self'; frame-ancestors 'none'; form-action 'none'; report-uri https://csp-reporter.ente.io; report-to https://csp-reporter.ente.io;

6 changes: 3 additions & 3 deletions src/utils/common/apiUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getFileUrl = (id: number) => {
'https://api.ente.io'
);
}
return `https://files.ente.workers.dev/?fileID=${id}`;
return `https://files.ente.io/?fileID=${id}`;
};

export const getThumbnailUrl = (id: number) => {
Expand All @@ -21,11 +21,11 @@ export const getThumbnailUrl = (id: number) => {
'https://api.ente.io'
);
}
return `https://thumbnails.ente.workers.dev/?fileID=${id}`;
return `https://thumbnails.ente.io/?fileID=${id}`;
};

export const getSentryTunnelUrl = () => {
return `https://sentry-reporter.ente.workers.dev`;
return `https://sentry-reporter.ente.io`;
};

export const getPaymentsUrl = () => {
Expand Down