|
3 | 3 | ## Context |
4 | 4 |
|
5 | 5 | * These notes are part of a broader set of [principles](../principles.md) |
6 | | -* TO DO: Reference to the Security Working Group (link to terms of reference?) |
7 | 6 | * This is related to [ARCHITECTURE-SECURITY](https://digital.nhs.uk/about-nhs-digital/our-work/nhs-digital-architecture/principles/adopt-appropriate-cyber-security-standards) |
8 | 7 |
|
9 | | -## Details |
10 | | - |
11 | | -* Everything (including infrastructure) should be up to date. |
12 | | -* Application dependencies should be automatically scanned for vulnerabilities & license issues. |
13 | | - * e.g. libraries, base container or VM images |
14 | | - * Scan before deployment and periodically in live for components no longer receiving regular deployments |
15 | | - * TO DO: guidance around setting team tolerances for warnings etc. |
16 | | -* Source code should be automatically scanned for secrets or other sensitive data (see [everything as code](../patterns/everything-as-code.md) for details). |
17 | | -* Nobody should need access to production hosts, including: |
18 | | - * Logging & monitoring should negate the need to manually inspect a production host. |
19 | | - * Deployments are immutable, and all deployments are issued via delivery pipelines, negating the need to manually change a production host. |
20 | | -* Any access to production must be audited and granted using temporary "break glass" permissions. |
21 | | -* Access to environments, secrets & credentials, etc must use role based access control with minimum privileges. |
22 | | -* Use public resources as well as organisation policies, for example [OWASP Top 10](https://owasp.org/www-project-top-ten/). |
| 8 | +## Big picture |
| 9 | + |
| 10 | +- Understand what **data** is processed or stored in the system |
| 11 | + - Assess the data classification e.g. personal confidential data (PCD), aggregate data, anonymised data, publicly available information. See [Health and social care data risk model](https://digital.nhs.uk/data-and-information/looking-after-information/data-security-and-information-governance/nhs-and-social-care-data-off-shoring-and-the-use-of-public-cloud-services/health-and-social-care-data-risk-model) |
| 12 | + - Understand governance and compliance requirements which apply, e.g. [NHS guidance](https://digital.nhs.uk/data-and-information/looking-after-information/data-security-and-information-governance/nhs-and-social-care-data-off-shoring-and-the-use-of-public-cloud-services/health-and-social-care-cloud-risk-framework), GDPR |
| 13 | +- Consider whether the data being processed is all **necessary** for the system to function, or whether it could be reduced to minimise risk |
| 14 | + - Prefer use of managed services to reduce attack surface where possible |
| 15 | +- Keep **audit** log(s) of user actions, software and infrastructure changes (e.g. git, CI/CD, [CloudTrail](https://aws.amazon.com/cloudtrail/)) |
| 16 | + |
| 17 | +## Application level security |
| 18 | + |
| 19 | +- Cover the **basics** |
| 20 | + - Ensure the [OWASP Top Ten](https://www.owasp.org/index.php/Category:OWASP_Top_Ten_2017_Project) is well understood and considered during software delivery |
| 21 | + - Encode/validate all user input. Code against (and test for) XSS and injection attacks such as SQL/XML/JSON/CRLF |
| 22 | +- Ensure **authentication** is robust |
| 23 | + - Strong passwords and MFA |
| 24 | + - Secure storage of session token (`Secure`, `HttpOnly` and `SameSite`) which is refreshed on privilege escalation to avoid session hijacking/fixation |
| 25 | + - Strong hash and salt if storing passwords |
| 26 | + - Clear and consistent permissions model |
| 27 | + - Minimum necessary feedback on failed authentication e.g. 404 or blanket 403 when not authenticated to avoid leaking whether resources exist |
| 28 | + - Guard against time based authentication attacks, e.g. using a WAF |
| 29 | +- Guarded against invalid **certificates** e.g. expiry monitoring. |
| 30 | + - Consider [OCSP stapling](https://blog.cloudflare.com/high-reliability-ocsp-stapling/) for improved performance |
| 31 | +- Ensure **cookies** cannot leak from production to non-produnction environments e.g. avoid non-produnction on subdomain of production domain |
| 32 | +- Prevent **[clickjacking](https://sudo.pagerduty.com/for_engineers/#clickjacking)** with `X-Frame-Options` |
| 33 | +- Be careful not to **leak information**, e.g. error messages, stack traces, headers |
| 34 | +- **Don't trust** yourself or others! |
| 35 | + - Scan source code automatically for secrets or other sensitive data (see [everything as code](../patterns/everything-as-code.md) for details) |
| 36 | + - Be wary of any 3rd party JavaScript included on the page, e.g. for A/B testing, analytics |
| 37 | + - Pin dependencies at known versions to avoid unexpected updates |
| 38 | + - Scan dependencies for vulnerabilities, e.g. using [OWASP Dependency Check](https://www.owasp.org/index.php/OWASP_Dependency_Check) or [Snyk](https://snyk.io/) |
| 39 | + - Scan running software, e.g. using [OWASP ZAP](https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project) |
| 40 | +- **Automate** security testing — on every build if practical |
| 41 | + - Generate test data in a way that avoids including personally identifiable information |
| 42 | + |
| 43 | +## Infrastructure security |
| 44 | + |
| 45 | +- **Encrypt** data at rest and in transit |
| 46 | + - TO DO: Statement on TLS versions |
| 47 | + - Consider enabling only [Perfect Forward Secrecy](https://en.wikipedia.org/wiki/Forward_secrecy) cipher suites (e.g. [ECDHE](https://en.wikipedia.org/wiki/Elliptic-curve_Diffie%E2%80%93Hellman)) |
| 48 | +- **Scan and refresh** systems and software when required to keep them secure, e.g. using [Prisma](https://www.paloaltonetworks.com/prisma/cloud/cloud-workload-protection-platform) (formerly Twistlock), [Clair](https://github.com/quay/clair) or [ECR image scanning](https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-scanning.html) for container base images, or [Amazon Inspector](https://aws.amazon.com/inspector/) for VMs |
| 49 | + - Scan before deployment and periodically in live for components no longer receiving regular deployments |
| 50 | +- **Minimise access** to production |
| 51 | + - Logging & monitoring should negate the need to manually inspect a production host |
| 52 | + - All deployments should be done via delivery pipelines, negating the need to manually change a production host |
| 53 | + - If possible, only allow access for emergencies using a "break glass" pattern, e.g. using Azure AD [Privileged Identity Management](https://docs.microsoft.com/en-us/azure/active-directory/privileged-identity-management/pim-configure) |
| 54 | + - Audit access to production and alert for unexpected access |
| 55 | +- Ensure infrastructure **IAM** is robust |
| 56 | + - Strong passwords and MFA |
| 57 | + |
| 58 | + <details><summary>Example IAM policy to prevent assume role without MFA (click to expand)</summary> |
| 59 | + |
| 60 | + ```yaml |
| 61 | + { |
| 62 | + "Version": "2012-10-17", |
| 63 | + "Statement": { |
| 64 | + "Effect": "Allow", |
| 65 | + "Action": "sts:AssumeRole", |
| 66 | + "Resource": "arn:aws:iam::<your_account_id>:role/Administrator", |
| 67 | + "Condition": { |
| 68 | + "BoolIfExists": { |
| 69 | + "aws:MultiFactorAuthPresent": "true" |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + ``` |
| 75 | + </details> |
| 76 | + - Segregate workloads, e.g. in separate AWS accounts ([Landing Zone](https://aws.amazon.com/solutions/aws-landing-zone/), [Control Tower](https://aws.amazon.com/controltower/features/)) or Azure [subscriptions](https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/decision-guides/subscriptions/) |
| 77 | + - Fine grained, least privilege IAM roles |
| 78 | +- Secure **CI/CD** |
| 79 | + - Robust authentication and minimum privileges |
| 80 | + - Prefer ambient IAM credentials over retrieving credentials from secrets management. Do not store credentials in the plain. |
| 81 | +- **Enforce** infrastructure security (e.g. [Azure Policy](https://docs.microsoft.com/en-us/azure/governance/policy/overview), [AWS Config](https://aws.amazon.com/config/)) and validate it (e.g. [ScoutSuite](https://github.com/nccgroup/ScoutSuite/blob/master/README.md)) |
| 82 | + |
| 83 | + <details><summary>Example IAM policy fragment to prevent unencrypted RDS databases (click to expand)</summary> |
| 84 | + |
| 85 | + ```yaml |
| 86 | + {ββββββββ |
| 87 | + "Sid": "", |
| 88 | + "Effect": "Deny", |
| 89 | + "Action": "rds:CreateDBInstance", |
| 90 | + "Resource": "*", |
| 91 | + "Condition": {ββββββββ |
| 92 | + "Bool": {ββββββββ |
| 93 | + "rds:StorageEncrypted": "false" |
| 94 | + } |
| 95 | + }ββββββββ |
| 96 | + }ββββββββ |
| 97 | + ``` |
| 98 | + </details> |
| 99 | +- Lock down your **networks** |
| 100 | + - Restrict external and internal network traffic by appropriate firewall rules |
| 101 | + - Consider using a WAF (Web Application Firewall) |
| 102 | + - Restrict outbound network calls to limit the damage a compromised component can do if practical |
| 103 | + |
| 104 | +## Human factors |
| 105 | +- Ensure **joiners and leavers process** is adequate |
| 106 | +- Encourage use of **password managers** with MFA enabled |
| 107 | +- Be aware of security sign-off **policies or procedures** outside the team and engage with these early |
0 commit comments