Upgrade to Pro — share decks privately, control downloads, hide ads and more …

High Assurance Secure Software Development on t...

High Assurance Secure Software Development on the Server Side

Charles Hubain (LINE Plus / Security R&D Team / Senior Security Engineer)
Jonas Lejeune (LINE / Security R&D Team / Senior Security Engineer)

https://tech-verse.me/ja/sessions/70
https://tech-verse.me/en/sessions/70
https://tech-verse.me/ko/sessions/70

Tech-Verse2022

November 17, 2022
Tweet

More Decks by Tech-Verse2022

Other Decks in Technology

Transcript

  1. Agenda 1. Background 2. Security Architecture 3. Hardware Security Module

    4. Intel® Software Guard Extensions 5. Practical Considerations
  2. 1. Backing up Letter Sealing keys 2. Maintain End-to-End Encryption

    guarantees 3. Resist external and internal threats Background More details available in the "Easier and Safer LINE Account Transfer” session
  3. Threat Model - Direct access to code, file and databases

    - Man-in-the-middle - Code backdoor - External threats - Attack through public APIs - Internal threats
  4. Backup of Letter Sealing keys ✳ LINE Developer Day 2019:

    Seamless device migration using LINE secure backups LINE Client
  5. Backup of Letter Sealing keys ✳ LINE Developer Day 2019:

    Seamless device migration using LINE secure backups LINE Client Backup Data
  6. Backup of Letter Sealing keys ✳ LINE Developer Day 2019:

    Seamless device migration using LINE secure backups LINE Client User PIN Backup Data
  7. Backup of Letter Sealing keys ✳ LINE Developer Day 2019:

    Seamless device migration using LINE secure backups LINE Client User PIN Public Key Backup Data
  8. Backup of Letter Sealing keys ✳ LINE Developer Day 2019:

    Seamless device migration using LINE secure backups LINE Client LINE Server Backup server Encrypted Backup Internet User PIN Public Key Backup Data
  9. Backup of Letter Sealing keys ✳ LINE Developer Day 2019:

    Seamless device migration using LINE secure backups LINE Client LINE Server Backup server Encrypted Backup Internet User PIN Public Key Private Key Backup Data
  10. Backup of Letter Sealing keys ✳ LINE Developer Day 2019:

    Seamless device migration using LINE secure backups LINE Client LINE Server Backup server Encrypted Backup Internet User PIN Public Key Private Key Attempt counters Backup Data
  11. External Threats Backup of Letter Sealing keys ✳ LINE Developer

    Day 2019: Seamless device migration using LINE secure backups LINE Client LINE Server Backup server Encrypted Backup Internet User PIN Public Key Private Key Attempt counters Backup Data
  12. Internal Threats External Threats Backup of Letter Sealing keys ✳

    LINE Developer Day 2019: Seamless device migration using LINE secure backups LINE Client LINE Server Backup server Encrypted Backup Internet User PIN Public Key Private Key Attempt counters Backup Data
  13. Trusted Execution Environment Internal Threats External Threats Backup of Letter

    Sealing keys ✳ LINE Developer Day 2019: Seamless device migration using LINE secure backups LINE Client LINE Server Backup server Encrypted Backup Internet User PIN Public Key Private Key Attempt counters Backup Data
  14. Security Architecture Mobile Device Service Certificate (statically provisioned) Trusted Execution

    Environment Secure Service Service Private Key LINE Server Authenticated Secure Channel
  15. Security Architecture Mobile Device Service Certificate (statically provisioned) Trusted Execution

    Environment Secure Service TEE Protected File Service Private Key LINE Server Authenticated Secure Channel
  16. Security Architecture Mobile Device Service Certificate (statically provisioned) Trusted Execution

    Environment Secure Service TEE Protected File Service Private Key Code Signing Key LINE Server Authenticated Secure Channel
  17. Security Architecture Mobile Device Service Certificate (statically provisioned) Trusted Execution

    Environment Secure Service TEE Protected File Service Private Key Code Signing Key Code Signature LINE Server Authenticated Secure Channel
  18. Security Architecture Mobile Device Service Certificate (statically provisioned) Trusted Execution

    Environment Secure Service TEE Protected File Service Private Key Code Signing Key Code Signature ACL LINE Server Authenticated Secure Channel
  19. Chain of Trust Service Certificate Code Signature Allow to Access

    Service Private Key Authenticate with Client
  20. Chain of Trust Service Certificate Code Signing Key Sign Code

    Signature Allow to Access Service Private Key Authenticate with Client
  21. Trusted Execution Environment Chain of Trust Service Certificate Code Signing

    Key Sign Code Signature Allow to Access Service Private Key Authenticate with Client
  22. Root of Trust - Code signing key becomes the root

    of trust - Only the code signing key has to be protected
  23. Root of Trust - Code signing key becomes the root

    of trust - Only the code signing key has to be protected - Can be protected offline with a high level of physical security
  24. Root of Trust - Code signing key becomes the root

    of trust - Only the code signing key has to be protected - Can be protected offline with a high level of physical security - Can also be destroyed
  25. Root of Trust - Code signing key becomes the root

    of trust - Only the code signing key has to be protected - Can be protected offline with a high level of physical security - Can also be destroyed ➡ Security by immutability
  26. Trusted Execution Environment - Hardware support for cryptographic features -

    Loading and executing signed code - Guarantee integrity and confidentiality
  27. Trusted Execution Environment - Hardware support for cryptographic features -

    Loading and executing signed code - Guarantee integrity and confidentiality - Many implementations:
  28. Trusted Execution Environment - Hardware support for cryptographic features -

    Loading and executing signed code - Guarantee integrity and confidentiality - Many implementations: - CPU feature: ARM® TrustZone®, Intel® SGX, …
  29. Trusted Execution Environment - Hardware support for cryptographic features -

    Loading and executing signed code - Guarantee integrity and confidentiality - Many implementations: - CPU feature: ARM® TrustZone®, Intel® SGX, … - Dedicated chips: Apple® Secure Enclave, Google® Titan
  30. Trusted Execution Environment - Hardware support for cryptographic features -

    Loading and executing signed code - Guarantee integrity and confidentiality - Many implementations: - CPU feature: ARM® TrustZone®, Intel® SGX, … - Dedicated chips: Apple® Secure Enclave, Google® Titan - Dedicated devices: Hardware Security Module
  31. Hardware Security Module HSM are dedicated hardware performing cryptographic operations

    - Designed to manage and protect cryptographic keys - Usually certified to comply with security standards (FIPS 140, CC, …)
  32. Hardware Security Module HSM are dedicated hardware performing cryptographic operations

    - Designed to manage and protect cryptographic keys - Usually certified to comply with security standards (FIPS 140, CC, …) High focus on the security of the device - Secure software implementations of cryptographic code - Resistance to side channel attacks (timing, power analysis, …) - Physical security is taken into account too - Sealed case, sensors to avoid probing, self-erasure feature, …
  33. Hardware Security Module HSM are dedicated hardware performing cryptographic operations

    - Designed to manage and protect cryptographic keys - Usually certified to comply with security standards (FIPS 140, CC, …) High focus on the security of the device - Secure software implementations of cryptographic code - Resistance to side channel attacks (timing, power analysis, …) - Physical security is taken into account too - Sealed case, sensors to avoid probing, self-erasure feature, … Might provide a Trusted Execution Environment (TEE)
  34. Main principles Main principles of an HSM - Keys are

    manipulated only within the HSM - Operations are done by requests to the HSM - Key usage restrictions with ACL - Trusted code is executed inside the HSM’s CPU HSM OS Crypto processor Application Key Key ID
  35. Main principles Main principles of an HSM - Keys are

    manipulated only within the HSM - Operations are done by requests to the HSM - Key usage restrictions with ACL - Trusted code is executed inside the HSM’s CPU HSM OS Crypto processor Application Key Key ID Key ID Plain text
  36. Main principles Main principles of an HSM - Keys are

    manipulated only within the HSM - Operations are done by requests to the HSM - Key usage restrictions with ACL - Trusted code is executed inside the HSM’s CPU HSM OS Crypto processor Application Key Key ID Key ID Plain text Key ID
  37. Main principles Main principles of an HSM - Keys are

    manipulated only within the HSM - Operations are done by requests to the HSM - Key usage restrictions with ACL - Trusted code is executed inside the HSM’s CPU HSM OS Crypto processor Application Key Key ID Key ID Plain text Key ID Key
  38. Main principles Main principles of an HSM - Keys are

    manipulated only within the HSM - Operations are done by requests to the HSM - Key usage restrictions with ACL - Trusted code is executed inside the HSM’s CPU HSM OS Crypto processor Application Key Key ID Key ID Plain text Key ID Plain text Key
  39. Main principles Main principles of an HSM - Keys are

    manipulated only within the HSM - Operations are done by requests to the HSM - Key usage restrictions with ACL - Trusted code is executed inside the HSM’s CPU HSM OS Crypto processor Application Key Key ID Key ID Plain text Key ID Plain text Cipher text Key
  40. Main principles Main principles of an HSM - Keys are

    manipulated only within the HSM - Operations are done by requests to the HSM - Key usage restrictions with ACL - Trusted code is executed inside the HSM’s CPU HSM OS Crypto processor Application Key Key ID Cipher text Key ID Plain text Key ID Plain text Cipher text Key
  41. Operational Costs of HSM Development complexity - Unusual development environment

    (CPU architecture, OS, …) - Suboptimal performances for general purpose computing
  42. Operational Costs of HSM Development complexity - Unusual development environment

    (CPU architecture, OS, …) - Suboptimal performances for general purpose computing High availability and high performance required - Unit price of an HSM is high - Spare units needed quickly in case of hardware failures
  43. Operational Costs of HSM Development complexity - Unusual development environment

    (CPU architecture, OS, …) - Suboptimal performances for general purpose computing High availability and high performance required - Unit price of an HSM is high - Spare units needed quickly in case of hardware failures Maintenance operations require physical presence - Might require several operators at the same time - Specific knowledge is required
  44. Intel® Software Guard Extensions What is Intel® SGX - Intel®

    proposal for Trusted Computing directly in the CPU - Implemented as 18 new assembly instructions - Security critical code is signed and isolated in an enclave - Enclaves are totally isolated from other processes
  45. Main principles Intel® SGX Developer Guide defines 3 objectives to

    have trusted computing: - Measurement: instantiation of the code in a trusted environment - Sealing: safe export of secret from the trusted environment - Attestation: provability that the code is running in a trusted environment
  46. Measurement of code Instantiation of the code in a trusted

    environment - Enclaves are signed at compilation time - Signature is verified when the enclave is loaded by the CPU - Enclave code can only be accessed at well-defined entry points
  47. Data Sealing Safe export of secrets from the trusted environment

    - SGX only guarantees the authenticity of the code, not its confidentiality - Enclave’s memory encryption is done with a random temporary key Impossible to provision or export secrets with these properties only.
  48. Data Sealing SGX provides a way to safely export data:

    - CPUs are provisioned with a Root Sealing Key (RSK), fused in the silicon - The RSK cannot be accessed directly, even by enclaves - Enclaves can request a derivation of the RSK to get their sealing key
  49. Sealing principles Trusted Environment Enclave Sealing Key Sealed Data Data

    SGX password RSK Untrusted Environment Application External Storage Enclave Signer Attributes
  50. Code Attestation Provability that the code is running in a

    trusted environment - Local attestation: attestation between 2 enclaves on the same machine - Remote attestation: attestation between an enclave and a remote 3rd party
  51. Local attestation Local attestation Enclave A Enclave B 1 2

    3 Machine with SGX - Performed between two enclaves running locally on the same machine - Takes advantage that the two enclaves share the same RSK - A secure channel can be established during the attestation process
  52. Remote attestation Remote attestation - Performed between an enclave and

    a remote 3rd party - Requires a Quoting Enclave and an external Attestation Service to verify enclave’s report - A secure channel can be established during the attestation process Enclave Machine with SGX 3rd Party Client
  53. Remote attestation Remote attestation - Performed between an enclave and

    a remote 3rd party - Requires a Quoting Enclave and an external Attestation Service to verify enclave’s report - A secure channel can be established during the attestation process Enclave Machine with SGX 3rd Party Client Quoting Enclave 1 2 3 4 5 Attestation Service
  54. SGX Security Architecture Mobile Device SGX Enclave Secure Service SGX

    Sealed Data Service Private Key Mobile Client
  55. SGX Security Architecture Mobile Device SGX Enclave Secure Service SGX

    Sealed Data Service Private Key Code Signing Key Mobile Client
  56. SGX Security Architecture Mobile Device SGX Enclave Secure Service SGX

    Sealed Data Service Private Key Code Signing Key Code Signature Mobile Client
  57. SGX Security Architecture Mobile Device SGX Enclave Secure Service SGX

    Sealed Data Service Private Key Code Signing Key Code Signature Sealing Key Derivation Mobile Client
  58. SGX Security Architecture Mobile Device Attestation PKI SGX Enclave Secure

    Service SGX Sealed Data Service Private Key Code Signing Key Code Signature Sealing Key Derivation Mobile Client
  59. SGX Security Architecture Mobile Device Attestation PKI SGX Enclave Secure

    Service SGX Sealed Data Service Private Key Code Signing Key Code Signature Enclave Attestation Sealing Key Derivation Mobile Client
  60. SGX Security Architecture Mobile Device Attestation PKI SGX Enclave Secure

    Service SGX Sealed Data Service Private Key Code Signing Key Code Signature Enclave Attestation Sealing Key Derivation Authenticated Secure Channel Mobile Client
  61. Are We More Secure? - Reduce the attack surface -

    Trusted Computing Base: Sum of components critical to security
  62. Are We More Secure? - Reduce the attack surface -

    Trusted Computing Base: Sum of components critical to security - No need to trust the OS / user applications
  63. Are We More Secure? - Reduce the attack surface -

    Trusted Computing Base: Sum of components critical to security - No need to trust the OS / user applications - Move security functions into hardware
  64. Are We More Secure? - Reduce the attack surface -

    Trusted Computing Base: Sum of components critical to security - No need to trust the OS / user applications - Move security functions into hardware - Hardware attack cost is much higher
  65. TCB Threats - Hardware vulnerabilities - Recent examples: ÆPIC leak,

    SEPROM bug, … - Cryptographic vulnerabilities
  66. TCB Threats - Hardware vulnerabilities - Recent examples: ÆPIC leak,

    SEPROM bug, … - Cryptographic vulnerabilities - Side channel attacks
  67. TCB Threats - Hardware vulnerabilities - Recent examples: ÆPIC leak,

    SEPROM bug, … - Cryptographic vulnerabilities - Side channel attacks - Insecure protocol design
  68. TCB Threats - Hardware vulnerabilities - Recent examples: ÆPIC leak,

    SEPROM bug, … - Cryptographic vulnerabilities - Side channel attacks - Insecure protocol design - Memory vulnerabilities
  69. TCB Threats - Hardware vulnerabilities - Recent examples: ÆPIC leak,

    SEPROM bug, … - Cryptographic vulnerabilities - Side channel attacks - Insecure protocol design - Memory vulnerabilities - Memory leaks
  70. TCB Threats - Hardware vulnerabilities - Recent examples: ÆPIC leak,

    SEPROM bug, … - Cryptographic vulnerabilities - Side channel attacks - Insecure protocol design - Memory vulnerabilities - Memory leaks - Arbitrary code execution
  71. TCB Threats - Hardware vulnerabilities - Recent examples: ÆPIC leak,

    SEPROM bug, … - Cryptographic vulnerabilities - Side channel attacks - Insecure protocol design - Memory vulnerabilities - Memory leaks - Arbitrary code execution Affect all TEEs, Can only mitigate
  72. Back To Secure Development - Cryptographic protocol design flaws -

    Formal verification can help: proverif - Memory vulnerabilities
  73. Back To Secure Development - Cryptographic protocol design flaws -

    Formal verification can help: proverif - Memory vulnerabilities - Testing and Fuzzing helps
  74. Back To Secure Development - Cryptographic protocol design flaws -

    Formal verification can help: proverif - Memory vulnerabilities - Testing and Fuzzing helps - Safer languages are better: Rust
  75. Rust - Higher level abstraction than C - Rich type

    system - Advanced generic programming
  76. Rust - Higher level abstraction than C - Rich type

    system - Advanced generic programming - Crates: module based dependency management
  77. Rust - Higher level abstraction than C - Rich type

    system - Advanced generic programming - Crates: module based dependency management - Designed with security in mind
  78. Rust - Higher level abstraction than C - Rich type

    system - Advanced generic programming - Crates: module based dependency management - Designed with security in mind - Compiler enforce memory safety, thread safety
  79. Rust - Higher level abstraction than C - Rich type

    system - Advanced generic programming - Crates: module based dependency management - Designed with security in mind - Compiler enforce memory safety, thread safety - Native with bare metal support
  80. Rust - Higher level abstraction than C - Rich type

    system - Advanced generic programming - Crates: module based dependency management - Designed with security in mind - Compiler enforce memory safety, thread safety - Native with bare metal support - Can be as fast as C
  81. Rust - Higher level abstraction than C - Rich type

    system - Advanced generic programming - Crates: module based dependency management - Designed with security in mind - Compiler enforce memory safety, thread safety - Native with bare metal support - Can be as fast as C - Can be used to write firmware, drivers, SGX enclave, …
  82. Rust at LINE - Currently only using it on the

    server application side - Excellent ecosystem for service development
  83. Rust at LINE - Currently only using it on the

    server application side - Excellent ecosystem for service development - Started using it for SGX enclave
  84. Rust at LINE - Currently only using it on the

    server application side - Excellent ecosystem for service development - Started using it for SGX enclave - Toolchains already exists: Apache Teaclave, Fortanix® EDP
  85. Rust at LINE - Currently only using it on the

    server application side - Excellent ecosystem for service development - Started using it for SGX enclave - Toolchains already exists: Apache Teaclave, Fortanix® EDP - Easy to make your own
  86. Rust at LINE - Currently only using it on the

    server application side - Excellent ecosystem for service development - Started using it for SGX enclave - Toolchains already exists: Apache Teaclave, Fortanix® EDP - Easy to make your own - Rust can output C compatible (FFI) object files
  87. Rust at LINE - Currently only using it on the

    server application side - Excellent ecosystem for service development - Started using it for SGX enclave - Toolchains already exists: Apache Teaclave, Fortanix® EDP - Easy to make your own - Rust can output C compatible (FFI) object files - Rust nostd code can be linked with Intel SDK
  88. Conclusions - Higher security assurance can be achieved on the

    server side - TEE can help prevent insider threats
  89. Conclusions - Higher security assurance can be achieved on the

    server side - TEE can help prevent insider threats - TEE can protect both data and code
  90. Conclusions - Higher security assurance can be achieved on the

    server side - TEE can help prevent insider threats - TEE can protect both data and code - Multiple TEE implementation available
  91. Conclusions - Higher security assurance can be achieved on the

    server side - TEE can help prevent insider threats - TEE can protect both data and code - Multiple TEE implementation available - Similar security architecture can be achieved
  92. Conclusions - Higher security assurance can be achieved on the

    server side - TEE can help prevent insider threats - TEE can protect both data and code - Multiple TEE implementation available - Similar security architecture can be achieved - Choice will depend on cost, performance, regulations, …
  93. Conclusions - Higher security assurance can be achieved on the

    server side - TEE can help prevent insider threats - TEE can protect both data and code - Multiple TEE implementation available - Similar security architecture can be achieved - Choice will depend on cost, performance, regulations, … - TEE TCB is still a target
  94. Conclusions - Higher security assurance can be achieved on the

    server side - TEE can help prevent insider threats - TEE can protect both data and code - Multiple TEE implementation available - Similar security architecture can be achieved - Choice will depend on cost, performance, regulations, … - TEE TCB is still a target - Safer programming languages are required