Third-Party Content

The weak link in your chain?

Simon Hearne - Principle Engineer @ Akamai

The modern web workflow 101

make something ๐Ÿค“

test it ๐Ÿ‘

ship it ๐Ÿ˜Ž

... 

put tags on it ๐Ÿ˜ณ

What I've learned in 5 years

we seem to have less control than ever

& there are increasingly more third-party providers

How I think I can help you

  1. Understand the risk they pose
  2. Discover & identify third-party tags
  3. How to monitor & and measure tags
  4. Building a business case for tags

Tags serve business goals

  • Measurement & Analytics
  • Ads & Retargeting
  • "Optimization" & Testing
  • Comments & Live Chat
  • Tag Management

but what about the

Risk?

๐ŸŽฒ

Risk 1:

Code Quality ๐Ÿ‘น

78.7%

of top 500k sites include JS
with known vulnerabilities

beta.httparchive.org/reports/state-of-the-web#pctVuln

CryptoJacking

www.theverge.com/2018/3/22/17147320/cryptojacking-8500-percentage-points-bitcoin-monero-spike-symantec-security-mining

It happens to the biggest players

twitter.com/nytimes/status/3958547840

Unintentional data collection

website tracking is a "security disaster waiting to happen"

freedom-to-tinker.com/2018/02/26/no-boundaries-for-credentials-password-leaks-to-mixpanel-and-session-replay-companies/

XSS Vulnerabilites

randywestergren.com/widespread-xss-vulnerabilities/

Different release schedules


<script src="//s7.addthis.com/addthis_widget.js" async></script>
					

How do you know when it changes?

www.addthis.com

Just plain thoughtless

discuss.newrelic.com/t/do-not-clear-the-resource-timing-buffer/

Code Quality ๐Ÿ”Ž

  • How do they protect themselves?
  • How do they protect your customers?

Risk 2:

Availability ๐Ÿ“‰

Availability = User Availability

  • Government / ISP interference
  • Content blocking (~10% of users*)
  • Random issues (1% of JS fails to load*)

* www.slideshare.net/ianfeather/frontend-resilience

Do they fail gracefully?

๐Ÿ‘

Do they fail gracefully?

Do they fail gracefully?

๐Ÿ‘Ž

Are they using a CDN?

(& is it as good as yours?)

What is their SLA for availability?

(& is it as good as yours?)

Optimizely support plans

Availability ๐Ÿ“‰

  • What happens when they fail?
  • How often could they fail?

Risk 3:

Performance ๐Ÿš€

Self-policing isn't good enough

status.optimizely.com

Tools aren't equal

orangevalley.nl/en/blog/9-ab-testing-tools-compared-on-site-speed-impact/

Resource Timing is the hero we need

 

https://www.w3.org/TR/resource-timing-1/

Resource Timing is the hero we need

not without Timing-Allow-Origin ๐Ÿ™ˆ

nicj.net/resourcetiming-visibility-third-party-scripts-ads-and-page-weight/

CPU is our biggest bottleneck โณ

The most frustrating perf bug, ever

Devices are not affected equally

Fast Fashionโ€ฆ How Missguided revolutionised their approach to site performance

Devices are not affected equally

Fast Fashionโ€ฆ How Missguided revolutionised their approach to site performance

Performance ๐Ÿš€

  • Does their performance affect yours?
  • Do they let you measure them?

Actions to take

DiscoveryImpactReportingCode QualityAvailabilityData LeakagePerformance
Removal ๐Ÿ—‘

Stage 1:

Find out what's there ๐Ÿ‘โ€๐Ÿ—จ

RequestMap

Synthetic Testing

Synthetic Testing (webpagetest)

Conducting an Audit

Identifying, Auditing, and Discussing Third Parties - CSS Wizardry

Real User Monitoring ๐Ÿฅƒ

Real User Monitoring ๐Ÿฅƒ

Akamai mPulse

Stage 2:

Determine the impact ๐Ÿ“‰

Synthetic Testing (webpagetest)

SPOF-O-Matic Chrome Extension

Synthetic Testing (webpagetest)

Synthetic Testing (webpagetest)

Resource Impact from RUM

Advertising Partners

Partner 1 = ~400ms slower than partner 2

Migrating all ads = ~100ms faster page load

Additional revenue ~= $8,000 per month

Large US publishing company

"Everything should have a value,
because everything has a cost"

Tim Kadlec

Stage 3:

Measure them and Report on them ๐Ÿ“Š

Content Security Policy ๐Ÿ‘ฎโ€

Content Security Policy ๐Ÿ‘ฎโ€

(report-only)


{
	"csp-report": {
		"document-uri": "https://yourwebsite.com/",
		"referrer": "",
		"violated-directive": "style-src",
		"effective-directive": "style-src",
		"original-policy": "",
		"disposition": "enforce",
		"blocked-uri": "inline",
		"line-number": 4,
		"column-number": 3,
		"source-file": "https://static.hotjar.com/c/hotjar-730716.js?sv=6",
		"status-code": 0,
		"script-sample": ""
	}
}
					

report-uri.com

Synthetic Testing ๐Ÿค–

blog.catchpoint.com/2018/01/10/using-catchpoint-to-analyze-third-party-impact/

RUM ๐Ÿฅƒ

The best way to monitor resources,
even with its limitations

๐Ÿฅƒ Waterfalls

Akamai mPulse

Actions to take

DiscoveryImpactReportingCode QualityAvailabilityData LeakagePerformance
Removal
Synthetic
RUM
CSP (RO)

Stage 4:

Defend ourselves ๐Ÿคผโ€

Content Security Policy ๐Ÿ‘ฎโ€

Content Security Policy ๐Ÿ‘ฎโ€๏ธ

caniuse.com/#feat=contentsecuritypolicy2

Sub-resource Integrity ๐Ÿ”

Sub-resource Integrity ๐Ÿ”


<link
rel="stylesheet"
href="//maxcdn.bootstrapcdn.com/.../bootstrap.min.css"
integrity="
sha256-8EtRe6XWoFEEhWiaPkLaw...=
sha512-/5KWJw2mvMO2ZM5fndVxU...=
"

crossorigin="anonymous">
											

<script
src="//ajax.googleapis.com/.../jquery.min.js"
integrity="
sha256-ivk71nXhz9nsyFDoYoGf2...=
sha512-7aMbXH03HUs6zO1R+pLye...=
"

crossorigin="anonymous"></script>
											
										

Service Worker ๐Ÿ’ช

Service Worker ๐Ÿ’ช


function timeout(delay) {
	return new Promise(function(resolve, reject) {
		setTimeout(function(){
			resolve(new Response('', {
				status: 408,
				statusText: 'Request timed out.'
			}));
		}, delay);
	});
}

self.addEventListener('fetch', function(event) {
	// Only fetch JavaScript files for now
	if (/\.js$/.test(event.request.url)) {
		event.respondWith(Promise.race([timeout(2000), fetch(event.request.url)]));
	} else {
		event.respondWith(fetch(event.request));
	}
});
											

calendar.perfplanet.com/2015/reducing-single-point-of-failure-using-service-workers/

Script Manager ๐Ÿ’ช

Self-hosting / Proxying โ˜”๏ธ

Self-hosting / Proxying โ˜”๏ธ

vwo.com/knowledge/host-vwo-javascript-files-on-your-server/

Self-hosting / Proxying โ˜”๏ธ

community.akamai.com/community/web-performance/blog/2016/01/13/5-ways-to-prevent-slow-3rd-party-front-end-services

Actions to take

DiscoveryImpactReportingCode QualityAvailabilityData LeakagePerformance
Removal
Synthetic
RUM
CSP (RO)
SRI / Versioning
CSP
ServiceWorker
Self Hosting

Have a third-party policy ๐Ÿ’ผ

  • What does it do?
  • Who uses it?
  • Whatโ€™s the risk to the site?
  • How do you remove it?

Third-party content may be a weak link

But it's here to stay

Five things you can do this week:

  • Know what's there (requestmap)
  • Measure their performance (WPT / mPulse)
  • Share the data (dashboards)
  • Have a solid defense (SRI & CSP)
  • Have third-party policy (with IT & business)

Further reading

https://www.soasta.com/solutions/3rd-party-management/

Thank you,
good luck!

๐Ÿšดโ€ @SimonHearne

๐Ÿ›  webperf.ninja/tools

๐Ÿ–ฅ shearne@akamai.com

@SimonHearne