+ All Categories
Home > Documents > Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal)...

Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal)...

Date post: 30-Jun-2020
Category:
Upload: others
View: 6 times
Download: 0 times
Share this document with a friend
49
Security on FHIR Andrew Marcus Healthcare Technology Lead Amsterdam, 14-16 November | @HL7 @Asymmetrik | #fhirdevdays18 | asymmetrik.com/fhir HL7®, FHIR® and the flame Design mark are registered trademarks of Health Level Seven International and are used with permission.
Transcript
Page 1: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Security on FHIRAndrew MarcusHealthcare Technology Lead

Amsterdam, 14-16 November | @HL7 @Asymmetrik | #fhirdevdays18 | asymmetrik.com/fhir

HL7®, FHIR® and the flame Design mark are registered trademarks of Health Level Seven International and are used with permission.

Page 2: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Your system can get hacked if:

● You’re building a FHIR server

● You’re building a FHIR app

● You’re building any kind of application

● You’re using Cloud Infrastructure

● You’re connected to the internet

● You’re not connected to the internet

Page 3: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Globally, in 2017:

● 53K+ reported incidents, 2,216 confirmed breaches

● Hacks primarily use known, unpatched vulnerabilities

● Healthcare sector is largest victim:

● 24% of all incidents

● 56% were from insidersSource: Verizon Data Breach Investigation Report 2018

Page 4: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Why do attackers target health systems?

Page 5: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

* apologies to South Park

Cyber Criminal Business Plan

Phase 1 Phase 2 Phase 3

Download hacker tools Profit!

Page 6: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Selling Bulk Personal Data

Hacking for profit

Identity Theft, Benefits Fraud Ransomware

76% of all attacks are financially motivated

Ransomware is now offered as a service

Source: Verizon Data Breach Investigation Report 2018

Motivation

Page 7: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Graffiti

Gaining advantage or making a statement

Espionage DDoS

Source: Verizon Data Breach Investigation Report 2018

Motivation

Spy on your competitors

Place statement on a website

Take down a website

Page 8: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Targeted personal attack

Get pain medsAlter drug tests

Change health records

Attack medical devices

Obtain health records

RevengeLookup celebrity

Kill patients

Motivation

Page 9: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

What do attackers want?

Business Sensitive Information

● Operations Data● Employee Lists

Personal Identifying Information (PII)

● Credit Cards● SSNs

Personal Health Information (PHI)

● Health Records● Device Data

Page 10: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Common types of attacks(an incomplete list)

Attacks usually involve many techniques

Page 11: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Using Bots to Scan for Vulnerabilities

Internet-Facing APIs

Application Code

Operating System

Internet

● Hackers are lazy

● Scripts test for all known vulnerabilities

● Might be randomly targeted

Database

Internet-Facing APIs

Attack

Page 12: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Thwart Bots

Apply all security patches

Use static code analysis• Snyk.io, Sonarqube, HP Fortify

Use a Web Application Firewall (WAF)

Close all unused portsDon’t assume attackers won’t know about latest vulnerabilities

Mitigation

Page 13: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

SQL/NoSQL Injection

Internet-Facing APIs

Application Code

Operating System

● Pass database commands directly from a browser○ Get additional records○ Change/delete data

● Also works with NoSQL databases, i.e. MongoDB

Database

Internet

Internet-Facing APIs

Application Code

Database

Attack

Page 14: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

An example of SQL Injection

Source: XKCD.com

Page 15: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Cross-Site Scripting (XSS)

Internet-Facing APIs

Application Code

Operating System

● Place bad JS on webpage and share with users

● JS can do bad things:○ Steal session cookie○ Install keylogger○ Read data on the page

Database

Internet

Internet-Facing APIs

Application Code

Attack

Page 16: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Block Injections

Always sanitize inputs

Use a database query abstraction layer (i.e. ORM)

Remove script tags from inputs before using

Look at OWASP Top-10 for good coding practices

Don’t trust the data in or out

Mitigation

Page 17: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Malicious HTML in FHIR Narrative

Internet-Facing APIs

Application Code

Operating System

● Include bad JS in HTML field of FHIR resource○ Runs in doctor’s scope

● Upload image attachment with executable payload○ Runs on server

Database

Internet

Internet-Facing APIs

Application Code

Database Operating System

Attack

Page 18: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Scrub Active ElementsScrub out all active elements• Not just onclick; also onhover,

onfocus, onerror…

Ensure image attachments are not executable

http://build.fhir.org/narrative.html

Open bug bounty! Never run unknown code

Auto-generate narrative

Mitigation

Page 19: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Compromised Credentials

Internet-Facing APIs

Application Code

Operating System

● Obtain credentials from user○ Phishing○ Brute-force

● Login as user

● Do anything user can do

Database

Internet

Internet-Facing APIs

Application Code

Database

CredentialsCredentials

Attack

Page 20: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Protect Credentials

Use 2FA, strong passwords and an org-wide password manager

Never share accounts

Don’t give employees more access than they need

Limit login attemptsPhishing is often the easiest way to get health data

Mitigation

Page 21: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

A word on passwords

Source: XKCD.com

Passwords should be long

Other rules no longer apply

Page 22: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Internet

Man-in-the-Middle Attack

Internet-Facing APIs

Application Code

Operating System

● Intercept request○ Spoof DNS○ Sniff network traffic

● Intercept communication○ Steal sensitive data○ Impersonate user

Database

Internet-Facing APIs

Application Code

Database

Fake Server

Attack

Page 23: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Encrypt Everything

Always use encryption!

At least TLS 1.2

At least 256-bit AES keys

Use trusted certificates

Lock your domain names• Purchase similar domains

Disable support immediatelyfor TLS 1.0, 1.1 and SHA1

Mitigation

Page 24: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Internet

OAuth2 Token Shenanigans

Internet-Facing APIs

Application Code

Operating System

● Acquire valid JWT token

● Acquire signature key

● Alter token and re-sign○ Escalate privileges○ Change scope○ Change patient ID

Database

Application Code

Attack

OAuth ServerOAuth Server

Database

Page 25: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Stop Token ForgeryRequire tokens for all actions

Validate tokens with server

Use short expiration and random state parameter

Always have a server for apps to hide client secrets

Use JWE instead of JWSDon’t trust tokens without verifying them

Mitigation

Page 26: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

JWS has a “none” signature algorithm

● If you say None, JWS validation tools say OK!● Unpatched JWS libraries still have this vulnerability

It is not OK. Use JWE instead

Payload Algorithm Signature

Page 27: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Querying for Unauthorized Data

Internet-Facing APIs

Application Code

Operating System

● Craft a clever query

● Surmise existence of recordshacker has no access to

Database

Internet

Application Code

Database

Attack

Page 28: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

What should happen when a patient queries /patients search endpoint?

Pop Quiz!

● Successful result containing only authorized records○ 1 record if criteria matches patient○ 0 records if criteria do not match patient

● Exclude any evidence that other records exist

Page 29: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Plug Leaky Queries

Missing/Unauthorized data should be indistinguishable

Think about timing attacks

Don’t reveal log messages for internal system errors

http://build.fhir.org/security.html#AccessDenied

Don’t reveal more that the user needs to know

Mitigation

Page 30: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Recursive Denial of Service

Internet-Facing APIs

Application Code

Operating System

● Craft a query resulting in recursive object nesting

● Slows server to a crawl

● Other users denied access

Database

Internet

Application Code

Internet-Facing APIs

Attack

Page 31: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Malicious Terminology Expansion

Internet-Facing APIs

Application Code

Operating System

● Reference a bad URL

● Server queries bad URL to check code or Structure Def

● Response exploits your server in some way

Database

Internet

Bad Terminology Server

Attack

Application Code

Operating System

Page 32: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Control Nesting

Validate response from other servers

Maintain a whitelist of terminology servers

Limit recursive queries

Use scalable infrastructure Never trust external URLs

Mitigation

Page 33: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Privilege EscalationLateral Movement

Internet-Facing APIs

Application Code

Operating SystemDatabase

Internet

Internet-Facing APIs

Application Code

Operating System

Attack

● Once in application,gain access to OS

● Escalate to root user● Probe network● Find sensitive data

Application Code

Operating SystemSensitive Database

Application CodeSensitive DatabaseOperating System

Page 34: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Minimize Access

Microsegment your network

Close unneeded ports

Create separate user accounts

Monitor network traffic

Rotate secret keys Don’t allow any service or user account access to more than strictly necessary

Mitigation

Page 35: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Covering Your Tracks

Internet-Facing APIs

Application Code

Operating System

● Once hacker is in, removes logs to hide actions

● Attack can go undetected for months

Database (with logs)

Internet

Internet-Facing APIs

Application Code

Database (with logs) Operating System

Attack

Page 36: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Log Everything

Isolate logs from other data• Application logs• System logs• AuditEvent, Provenance

Make logs append-only

Use cloud-based logging• Elk, Splunk, Cloudwatch, etc

Don’t store your logs with the rest of your data

Mitigation

Page 37: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

On-Prem Network

Example: a micro-segmented network

Unsecure NetworkHIPAA-Compliant

NetworkHIPAA-Compliant

VPN Network

VPNVPN

Internet

Public Website(e.g. Wordpress)

Secure Website(e.g. Patient Portal)

Service Proxy(e.g. LDAP)

Internal Service(e.g. LDAP)

Logging Services

X

Page 38: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Phoenix FHIR®

ServerSecurity Focused

Web-Scale Technologie

s

Datasource Agnostic

Extensible

● Open-Source on Node JS

● Easy to implement

● Supports any version of FHIR®

● Supports GraphQL

● Robust security framework

Page 39: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Security is built-in

Implements security best practices

Validates all data in and out

Separates log storage

Fully supports OAuth2 / SMART

Enforces authorization with scopes

Security tested as part of ONC Challenge● All findings reported publicly● All vulnerabilities were fixed

Page 40: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

What’s your responsibility?

Page 41: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Defense is both deep and broad

Defense in Depth:• Must have security at every layer

Limit the Blast Radius:• Ensure a breach in one system

can’t spread to other systems

Page 42: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

DevSecOpsDevelopmen

tSecurit

yOperations

Security is everyone’s problem

As a developer, it’s your responsibility to secure your code

Page 43: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

http://build.fhir.org/security.html

• OAuth2

• Narrative

• Access Denied

• Error Handling

• Security Labels

Implement the security parts of FHIR

Page 44: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Security Labels

http://build.fhir.org/security-labels.html

● Provide finer-grained access control than scopes

● You must honor them● Do Not Store

● Delete After Use

Page 45: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

There is no silver bullet for security● Protect as much as you can

● Keep your systems patched

● Conduct penetration testingon your own systems

● Offer bug bounties

● Expect the unexpected

Page 46: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

● Go to FHIR DevDays Exercises and download our VM○ Contains insufficiently-secure FHIR server○ Contains hacking tools and instructions○ Contains some hidden vulnerabilities

Try out our hacking challenge

Page 47: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Security ResourcesFHIR Security Standards● https://www.hl7.org/fhir/security.html

SMART-on-FHIR Security Best Practices● http://docs.smarthealthit.org/authorization/best-practices/

OWASP Top-Ten Project● https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project

Verizon Data Breach Investigation Report● https://enterprise.verizon.com/resources/reports/dbir/

Page 48: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Get Free Stuff!

https://asymmetrik.com/fhir

● Phoenix FHIR® Server code

● Blog Posts

● Podcasts

● … and some songs

Page 49: Security on FHIR - FHIR DevDays€¦ · (e.g. Wordpress) Secure Website (e.g. Patient Portal) Service Proxy (e.g. LDAP) Internal Service (e.g. LDAP) Logging Services. X. Phoenix FHIR®

Andrew [email protected]

Thank You!

https://asymmetrik.com/fhir


Recommended