Part 1
요약·해설
Zephyr security process는 Secure Development, Secure Design, Security Certification의 세 축으로 구성됩니다. Code quality만 확인하는 데서 끝나지 않고 asset·threat·countermeasure를 연결하고, test와 audit evidence로 그 효과를 입증합니다.
Architecture · Coding · QA
Asset · Threat · Mitigation
Target · Claim · Evidence
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
1F7BE141886B840E21DE9EA6ED5C7C3DC64282C4B8AF6B4F239D2BF6466EB80B
.. _security-overview:
Zephyr Security Overview
########################
Introduction
************
This document outlines the steps of the Zephyr Security Subcommittee towards a
defined security process that helps developers build more secure
software while addressing security compliance requirements. It presents
the key ideas of the security process and outlines which documents need
to be created. After the process is implemented and all supporting
documents are created, this document is a top-level overview and entry
point.
Overview and Scope
==================
We begin with an overview of the Zephyr development process, which
mainly focuses on security functionality.
In subsequent sections, the individual parts of the process are treated
in detail. As depicted in Figure 1, these main steps are:
1. **Secure Development:** Defines the system architecture and
development process that ensures adherence to relevant coding
principles and quality assurance procedures.
2. **Secure Design:** Defines security procedures and implement measures
to enforce them. A security architecture of the system and
relevant sub-modules is created, threats are identified, and
countermeasures designed. Their correct implementation and the
validity of the threat models are checked by code reviews.
Finally, a process shall be defined for reporting, classifying,
and mitigating security issues.
3. **Security Certification:** Defines the certifiable part of the
Zephyr RTOS. This includes an evaluation target, its assets, and
how these assets are protected. Certification claims shall be
determined and backed with appropriate evidence.
.. figure:: ../../../security/media/security-process-steps.png
Figure 1. Security Process Steps
Intended Audience
=================
This document is a guideline for the development of a security process
by the Zephyr Security Subcommittee and the Zephyr Technical Steering
Committee. It provides an overview of the Zephyr security process for
(security) engineers and architects.
Nomenclature
============
In this document, the keywords "MUST", "MUST NOT", "REQUIRED", "SHALL",
"SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" are to be interpreted as described in [RFC2119]_.
These words are used to define absolute requirements (or prohibitions),
highly recommended requirements, and truly optional requirements. As
noted in RFC-2119, "These terms are frequently used to specify behavior
with security implications. The effects on security of not implementing
a MUST or SHOULD, or doing something the specification says MUST NOT or
SHOULD NOT be done may be very subtle. Document authors should take the
time to elaborate the security implications of not following
recommendations or requirements as most implementors will not have had
the benefit of the experience and discussion that produced the
specification."
Security Document Update
========================
This document is a living document. As new requirements, features, and
changes are identified, they will be added to this document through the
following process:
1. Changes will be submitted from the interested party(ies) via pull
requests to the Zephyr documentation repository.
2. The Zephyr Security Subcommittee will review these changes and provide feedback
or acceptance of the changes.
3. Once accepted, these changes will become part of the document.
Current Security Definition
***************************
This section recapitulates the current status of secure development
within the Zephyr RTOS. Currently, focus is put on functional security
and code quality assurance, although additional security features are
scoped.
The three major security measures currently implemented are:
- **Security** **Functionality** with a focus on cryptographic
algorithms and protocols. Support for cryptographic hardware is
scoped for future releases. The Zephyr runtime architecture is a
monolithic binary and removes the need for dynamic loaders,
thereby reducing the exposed attack surface.
- **Quality Assurance** is driven by using a development process that
requires all code to be reviewed before being committed to the
common repository. Furthermore, the reuse of proven building
blocks such as network stacks increases the overall quality level
and guarantees stable APIs. Static code analyses provide additional
quality checks.
- **Execution Protection** including thread separation, stack and
memory protection is currently available in the upstream
Zephyr RTOS starting with version 1.9.0 (stack protection). Memory
protection and thread separation were added in version 1.10.0 for X86
and in version 1.11.0 for ARM and ARC.
These topics are discussed in more detail in the following subsections.
Security Functionality
======================
The security functionality in Zephyr hinges mainly on the inclusion of
cryptographic algorithms, and on its monolithic system design.
The cryptographic features are provided through PSA Crypto, with
mbedTLS as the underlying implementation. Applications leverage PSA
Crypto APIs, ensuring a standardized and secure approach to
cryptographic operations. mbedTLS, as the implementation of PSA
Crypto, supports a wide range of cryptographic algorithms, making it
suitable for various application requirements.
APIs for vendor specific cryptographic IPs in both hardware and software
are planned, including secure key storage in the form of secure access
modules (SAMs), Trusted Platform Modules (TPMs), and
Trusted Execution Environments (TEEs).
The security architecture is based on a monolithic design where the
Zephyr kernel and all applications are compiled into a single static
binary. System calls are implemented as function calls without requiring
context switches. Static linking eliminates the potential for
dynamically loading malicious code.
Additional protection features are available in later releases. Stack
protection mechanisms are provided to protect against stack overruns.
In addition, applications can take advantage of thread separation
features to split the system into privileged and unprivileged execution
environments. Memory protection features provide the capability to
partition system resources (memory, peripheral address space, etc.) and
assign resources to individual threads or groups of threads. Stack,
thread execution level, and memory protection constraints are enforced
at the time of context switch.
Quality Assurance
=================
The Zephyr project uses an automated quality assurance process. The goal
is to have a process including mandatory code reviews, feature and issue
management/tracking, and static code analyses.
Code reviews are documented and enforced using a voting system before
getting checked into the repository by the responsible subsystem's
maintainer. The main goals of the code review are:
- Verifying correct functionality of the implementation
- Increasing the readability and maintainability of the contributed
source code
- Ensuring appropriate usage of string and memory functions
- Validation of the user input
- Reviewing the security relevant code for potential issues
The current coding principles focus mostly on coding styles and
conventions. Functional correctness is ensured by the build system and
the experience of the reviewer. Especially for security relevant code,
concrete and detailed guidelines need to be developed and aligned with
the developers (see: :ref:`secure code`).
Static code analyses are run on the Zephyr code tree on a regular basis,
see :ref:`static_analysis`.
Bug and issue tracking and management is performed using Github. The term
"survivability" was coined to cover pro-active security tasks such as
security issue categorization and management. A problem identified as
vulnerability is managed within Github security advisories.
Issues determined by static analyses should have more stringent reviews before
they are closed as non-issues (at least another person educated in
security processes need to agree on non-issue before closing).
A security subcommittee has been formed to develop a security process in
more detail; this document is part of that process.
Execution Protection
====================
Execution protection is supported and can be categorized into the
following tasks:
- **Memory separation:** Memory will be partitioned into regions and
assigned attributes based on the owner of that region of memory.
Threads will only have access to regions they control.
- **Stack protection:** Stack guards would provide mechanisms for
detecting and trapping stack overruns. Individual threads should
only have access to their own stacks.
- **Thread separation:** Individual threads should only have access to
their own memory resources. As threads are scheduled, only memory
resources owned by that thread will be accessible. Topics such as
program flow protection and other measures for tamper resistance
are currently not in scope.
System Level Security (Ecosystem, ...)
======================================
System level security encompasses a wide variety of categories. Some
examples of these would be:
- Secure/trusted boot
- Over the air (OTA) updates
- External Communication
- Device authentication
- Access control of onboard resources
- Flash updating
- Secure storage
- Peripherals
- Root of trust
- Reduction of attack surface
Some of these categories are interconnected and rely on multiple pieces
to be in place to produce a full solution for the application.
Secure Development Process
**************************
The development of secure code shall adhere to certain criteria. These
include coding guidelines and development processes that can be roughly
separated into two categories related to software quality and related to
software security. Furthermore, a system architecture document shall be
created and kept up-to-date with future development.
System Architecture
===================
.. figure:: ../../../security/media/security-zephyr-system-architecture.png
Figure 2: Zephyr System Architecture
A high-level schematic of the Zephyr system architecture is given in
Figure 2. It separates the architecture into an OS part (*kernel + OS
Services*) and a user-specific part (*Application Services*). The OS
part itself contains low-level, platform specific drivers and the
generic implementation of I/O APIs, file systems, kernel-specific
functions, and the cryptographic library.
A document describing the system architecture and design choices shall
be created and kept up to date with future development. This document
shall include the base architecture of the Zephyr OS and an overview of
important submodules. For each of the modules, a dedicated architecture
document shall be created and evaluated against the implementation.
These documents shall serve as an entry point to new developers and as a
basis for the security architecture. Please refer to the
:ref:`Zephyr subsystem documentation <os_services>` for
detailed information.
Secure Coding
=============
Designing an open software system such as Zephyr to be secure requires
adhering to a defined set of design standards. These standards are
included in the Zephyr Project documentation, specifically in its
:ref:`secure code` section. In [SALT75]_, the following, widely
accepted principles for protection mechanisms are defined to prevent
security violations and limit their impact:
- **Open design** as a design principle incorporates the maxim that
protection mechanisms cannot be kept secret on any system in
widespread use. Instead of relying on secret, custom-tailored
security measures, publicly accepted cryptographic algorithms and
well established cryptographic libraries shall be used.
- **Economy of mechanism** specifies that the underlying design of a
system shall be kept as simple and small as possible. In the
context of the Zephyr project, this can be realized, e.g., by
modular code [PAUL09]_ and abstracted APIs.
- **Complete mediation** requires that each access to every object and
process needs to be authenticated first. Mechanisms to store
access conditions shall be avoided if possible.
- **Fail-safe defaults** defines that access is restricted by default
and permitted only in specific conditions defined by the system
protection scheme, e.g., after successful authentication.
Furthermore, default settings for services shall be chosen in a
way to provide maximum security. This corresponds to the "Secure
by Default" paradigm [MS12]_.
- **Separation of privilege** is the principle that two conditions or
more need to be satisfied before access is granted. In the
context of the Zephyr project, this could encompass split keys
[PAUL09]_.
- **Least privilege** describes an access model in which each user,
program and thread shall have the smallest possible
subset of permissions in the system required to perform their
task. This positive security model aims to minimize the attack
surface of the system.
- **Least common mechanism** specifies that mechanisms common to more
than one user or process shall not be shared if not strictly
required. The example given in [SALT75]_ is a function that should
be implemented as a shared library executed by each user and not
as a supervisor procedure shared by all users.
- **Psychological acceptability** requires that security features are
easy to use by the developers in order to ensure its usage and
the correctness of its application.
In addition to these general principles, the following points are
specific to the development of a secure RTOS:
- **Complementary Security/Defense in Depth:** do not rely on a single
threat mitigation approach. In case of the complementary security
approach, parts of the threat mitigation are performed by the
underlying platform. In case such mechanisms are not provided by
the platform, or are not trusted, a defense in depth [MS12]_
paradigm shall be used.
- **Less commonly used services off by default**: to reduce the
exposure of the system to potential attacks, features or services
shall not be enabled by default if they are only rarely used (a
threshold of 80% is given in [MS12]_). For the Zephyr project,
this can be realized using the configuration management. Each
functionality and module shall be represented as a configuration
option and needs to be explicitly enabled. Then, all features,
protocols, and drivers not required for a particular use case can
be disabled. The user shall be notified if low-level options and
APIs are enabled but not used by the application.
- **Change management:** to guarantee a traceability of changes to the
system, each change shall follow a specified process including a
change request, impact analysis, ratification, implementation,
and validation phase. In each stage, appropriate documentation
shall be provided. All commits shall be related to a bug report
or change request in the issue tracker. Commits without a valid
reference shall be denied.
Based on these design principles and commonly accepted best practices, a
secure development guide shall be developed, published, and implemented
into the Zephyr development process. Further details on this are given
in the `Secure Design`_ section.
Quality Assurance
=================
The quality assurance part encompasses the following criteria:
- **Adherence to the Coding Conventions** with respect to coding style,
naming schemes of modules, functions, variables, and so forth.
This increases the readability of the Zephyr code base and eases
the code review. These coding conventions are enforced by
automated scripts prior to check-in.
- **Adherence to Deployment Guidelines** is required to ensure
consistent releases with a well-documented feature set and a
trackable list of security issues.
- **Code Reviews** ensure the functional correctness of the code base
and shall be performed on each proposed code change prior to
check-in. Code reviews shall be performed by at least one
independent reviewer other than the author(s) of the code change.
These reviews shall be performed by the subsystem maintainers and
developers on a functional level and are to be distinguished from
security reviews as laid out in the `Secure Design`_ section.
Refer to the :ref:`development_model` documentation for more information.
- **Static Code Analysis** tools efficiently detect common coding
mistakes in large code bases. All code shall be analyzed using an
appropriate tool prior to merges into the main repository. This
is not per individual commit, but is to be run on some interval
on specific branches. It is mandatory to remove all findings or
waive potential false-positives before each release.
Waivers shall be documented centrally and
in the form of a comment inside the source code itself. The
documentation shall include the employed tool and its version,
the date of the analysis, the branch and parent revision number,
the reason for the waiver, the author of the respective code, and
the approver(s) of the waiver. This shall as a minimum run on the
main release branch and on the security branch. It shall be
ensured that each release has zero issues with regard to static
code analysis (including waivers).
Refer to the :ref:`development_model` documentation for more information.
- **Complexity Analyses** shall be performed as part of the development
process and metrics such as cyclomatic complexity shall be
evaluated. The main goal is to keep the code as simple as
possible.
- **Automation:** the review process and checks for coding rule
adherence are a mandatory part of the precommit checks. To
ensure consistent application, they shall be automated as part of
the precommit procedure. Prior to merging large pieces of code
in from subsystems, in addition to review process and coding rule
adherence, all static code analysis must have been run and issues
resolved.
Release and Lifecycle Management
================================
Lifecycle management contains several aspects:
- **Device management** encompasses the possibility to update the
operating system and/or security related sub-systems of Zephyr
enabled devices in the field.
- **Lifecycle management:** system stages shall be defined and
documented along with the transactions between the stages in a
system state diagram. For security reasons, this shall include
locking of the device in case an attack has been detected, and a
termination if the end of life is reached.
- **Release management** describes the process of defining the release
cycle, documenting releases, and maintaining a record of known
vulnerabilities and mitigations. Especially for certification
purposes the integrity of the release needs to be ensured in a
way that later manipulation (e.g., inserting of backdoors, etc.)
can be easily detected.
- **Rights management and NDAs:** if required by the chosen
certification, the confidentiality and integrity of the system
needs to be ensured by an appropriate rights management (e.g.,
separate source code repository) and non-disclosure agreements
between the relevant parties. In case of a repository shared
between several parties, measures shall be taken that no
malicious code is checked in.
These points shall be evaluated with respect to their impact on the
development process employed for the Zephyr project.
Secure Design
*************
In order to obtain a certifiable system or product, the security process
needs to be clearly defined and its application needs to be monitored
and driven. This process includes the development of security related
modules in all of its stages and the management of reported security
issues. Furthermore, threat models need to be created for currently
known and future attack vectors, and their impact on the system needs to
be investigated and mitigated. Please refer to the
:ref:`secure code` outlined in the Zephyr project documentation
for detailed information.
The software security process includes:
- **Adherence to the Secure Development Coding** is mandatory to
avoid that individual components breach the system security and
to minimize the vulnerability of individual modules. While this
can be partially achieved by automated tests, it is inevitable to
investigate the correct implementation of security features such
as countermeasures manually in security-critical modules.
- **Security Reviews** shall be performed by a security architect in
preparation of each security-targeted release and each time a
security-related module of the Zephyr project is changed. This
process includes the validation of the effectiveness of
implemented security measures, the adherence to the global
security strategy and architecture, and the preparation of audits
towards a security certification if required.
- **Security Issue Management** encompasses the evaluation of potential
system vulnerabilities and their mitigation as described in
:ref:`Security Issue Management <reporting>`.
These criteria and tasks need to be integrated into the development
process for secure software and shall be automated wherever possible. On
system level, and for each security related module of the secure branch
of Zephyr, a directly responsible security architect shall be defined to
guide the secure development process.
Security Architecture
=====================
The general guidelines above shall be accompanied by an architectural
security design on system- and module-level. The high level
considerations include
- The identification of **security and compliance requirements**
- **Functional security** such as the use of cryptographic functions
whenever applicable
- Design of **countermeasures** against known attack vectors
- Recording of security relevant **auditable events**
- Support for **Trusted Platform Modules (TPM)** and
**Trusted Execution Environments (TEE)**
- Mechanisms to allow for **in-the-field** **updates** of devices using
Zephyr
- Task scheduler and separation
The security architecture development is based on assets derived from
the structural overview of the overall system architecture. Based on
this, the individual steps include:
1. **Identification of assets** such as user data, authentication and
encryption keys, key generation data (obtained from RNG),
security relevant status information.
2. **Identification of threats** against the assets such as breaches of
confidentiality, manipulation of user data, etc.
3. **Definition of requirements** regarding security and protection of
the assets, e.g., countermeasures or memory protection schemes.
The security architecture shall be harmonized with the existing system
architecture and implementation to determine potential deviations and
mitigate existing weaknesses. Newly developed sub-modules that are
integrated into the secure branch of the Zephyr project shall provide
individual documents describing their security architecture.
Additionally, their impact on the system level security shall be
considered and documented.
Security Vulnerability Reporting
================================
Please see :ref:`reporting` for information on reporting security
vulnerabilities.
Threat Modeling and Mitigation
==============================
The modeling of security threats against the Zephyr RTOS is required for
the development of an accurate security architecture and for most
certification schemes. The first step of this process is the definition
of assets to be protected by the system. The next step then models how
these assets are protected by the system and which threats against them
are present. After a threat has been identified, a corresponding threat
model is created. This model contains the asset and system
vulnerabilities, as well as the description of the potential exploits of
these vulnerabilities. Additionally, the impact on the asset, the module
it resides in, and the overall system is to be estimated. This threat
model is then considered in the module and system security architecture
and appropriate countermeasures are defined to mitigate the threat or
limit the impact of exploits.
In short, the threat modeling process can be separated into these steps
(adapted from [OWASP]_):
1. Definition of assets
2. Application decomposition and creation of appropriate data flow
diagrams (DFDs)
3. Threat identification and categorization using the [STRIDE09]_ and
[CVSS]_ approaches
4. Determination of countermeasures and other mitigation approaches
This procedure shall be carried out during the design phase of modules
and before major changes of the module or system architecture.
Additionally, new models shall be created, or existing ones shall be
updated whenever new vulnerabilities or exploits are discovered. During
security reviews, the threat models and the mitigation techniques shall
be evaluated by the responsible security architect.
From these threat models and mitigation techniques tests shall be
derived that prove the effectiveness of the countermeasures. These tests
shall be integrated into the continuous integration workflow to ensure
that the security is not impaired by regressions.
Vulnerability Analyses
======================
In order to find weak spots in the software implementation,
vulnerability analyses (VA) shall be performed. Of special interest are
investigations on cryptographic algorithms, critical OS tasks, and
connectivity protocols.
On a pure software level, this encompasses
- **Penetration testing** of the RTOS on a particular hardware
platform, which involves testing the respective Zephyr OS
configuration and hardware as one system.
- **Side channel attacks** (timing invariance, power invariance, etc.)
should be considered. For instance, ensuring **timing
invariance** of the cryptographic algorithms and modules is
required to reduce the attack surface. This applies to both the
software implementations and when using cryptographic hardware.
- **Fuzzing tests** shall be performed on both exposed APIs and
protocols.
The list given above serves primarily illustration purposes. For each
module and for the complete Zephyr system (in general on a particular
hardware platform), a suitable VA plan shall be created and executed.
The findings of these analyses shall be considered in the security issue
management process, and learnings shall be formulated as guidelines and
incorporated into the secure coding guide.
If possible (as in case of fuzzing analyses), these tests shall be
integrated into the continuous integration process.
Security Certification
**********************
One goal of creating a secure branch of the Zephyr RTOS is to create a
certifiable system or certifiable submodules thereof. The certification
scope and scheme are yet to be decided. However, many certifications such
as Common Criteria [CCITSE12]_ require evidence that the evaluation
claims are indeed fulfilled, so a general certification process is
outlined in the following. Based on the final choices for the
certification scheme and evaluation level, this process needs to be
refined.
Generic Certification Process
=============================
In general, the steps towards a certification or precertification
(compare [MICR16]_) are:
1. The **definition of assets** to be protected within the Zephyr RTOS.
Potential candidates are confidential information such as
cryptographic keys, user data such as communication logs, and
potentially IP of the vendor or manufacturer.
2. Developing a **threat model** and **security architecture** to
protect the assets against exploits of vulnerabilities of the
system. As a complete threat model includes the overall product
including the hardware platform, this might be realized by a
split model containing a precertified secure branch of Zephyr
which the vendor could use to certify their Zephyr-enabled
product.
3. Formulating an **evaluation target** that includes the
**certification claims** on the security of the assets to be
evaluated and certified, as well as assumptions on the operating
conditions.
4. Providing **proof** that the claims are fulfilled. This includes
consistent documentation of the security development process,
etc.
These steps are partially covered in previous sections as well. In
contrast to these sections, the certification process only requires to
consider those components that shall be covered by the certification.
The security architecture, for example, considers assets on system level
and might include items not relevant for the certification.
Certification Options
=====================
For the security certification as such, the following options can be
pursued:
1. **Abstract precertification of Zephyr as a pure software system:**
this option requires assumptions on the underlying hardware
platform and the final application running on top of Zephyr. If
these assumptions are met by the hardware and the application, a
full certification can be more easily achieved. This option is
the most flexible approach but puts the largest burden on the
product vendor.
2. **Certification of Zephyr on specific hardware platform without a
specific application in mind:** this scenario describes the
enablement of a secure platform running the Zephyr RTOS. The
hardware manufacturer certifies the platform under defined
assumptions on the application. If these are met, the final
product can be certified with little effort.
3. **Certification of an actual product:** in this case, a full product
including a specific hardware, the Zephyr RTOS, and an
application is certified.
In all three cases, the certification scheme (e.g., FIPS 140-2 [NIST02]_
or Common Criteria [CCITSE12]_), the scope of the certification
(main-stream Zephyr, security branch, or certain modules), and the
certification/assurance level need to be determined.
In case of partial certifications (options 1 and 2), assumptions on
hardware and/or software are required for certifications. These can
include [GHS10]_
- **Appropriate physical security** of the hardware platform and its
environment.
- **Sufficient protection of storage and timing channels** on
the hardware platform itself and all connected devices. (No mentioning of
remote connections.)
- Only **trusted/assured applications** running on the device
- The device and its software stack is configured and operated by
**properly trained and trusted individuals** with no malicious
intent.
These assumptions shall be part of the security claim and evaluation
target documents.
Part 3
한국어 전문 번역
소개
이 문서는 개발자가 더 안전한 software를 만들고 security compliance requirement에도 대응할 수 있도록, Zephyr Security Subcommittee가 명확한 security process를 수립해 가는 단계를 설명합니다. Security process의 핵심 생각과 새로 작성해야 할 문서를 제시합니다. Process와 지원 문서가 모두 마련된 뒤에는 이 문서가 전체 구조를 보여 주는 최상위 개요이자 시작점 역할을 합니다.
개요와 범위
먼저 security functionality에 주로 초점을 맞춘 Zephyr 개발 process의 전체 모습을 살펴봅니다.
뒤 절에서는 process의 각 부분을 자세히 다룹니다. 그림 1에 나타난 주요 단계는 다음과 같습니다.
- Secure Development: 관련 coding principle과 quality assurance procedure를 지키도록 system architecture와 개발 process를 정의합니다.
- Secure Design: Security procedure를 정의하고 이를 강제할 조치를 구현합니다. System과 관련 submodule의 security architecture를 만들고, threat를 식별한 뒤 countermeasure를 설계합니다. Code review로 countermeasure가 올바르게 구현됐는지와 threat model이 유효한지 확인합니다. 마지막으로 security issue를 보고하고 분류하며 완화하는 process를 정의해야 합니다.
- Security Certification: Zephyr RTOS에서 인증 가능한 부분을 정의합니다. 여기에는 evaluation target, 보호해야 할 asset과 asset 보호 방법이 포함됩니다. Certification claim을 결정하고 적절한 evidence로 뒷받침해야 합니다.

대상 독자
이 문서는 Zephyr Security Subcommittee와 Zephyr Technical Steering Committee가 security process를 개발할 때 사용하는 guideline입니다. Security engineer와 architect에게 Zephyr security process의 전체 모습을 제공합니다.
용어 규칙
이 문서의 ‘MUST’, ‘MUST NOT’, ‘REQUIRED’, ‘SHALL’, ‘SHALL NOT’, ‘SHOULD’, ‘SHOULD NOT’, ‘RECOMMENDED’, ‘MAY’, ‘OPTIONAL’은 RFC 2119의 의미로 해석해야 합니다.
이 단어들은 절대적인 requirement 또는 prohibition, 강하게 권고하는 requirement, 정말로 선택 가능한 requirement를 구분합니다. RFC 2119가 지적하듯 이런 용어는 security implication이 있는 동작을 규정할 때 자주 쓰입니다. MUST나 SHOULD를 구현하지 않거나, specification이 MUST NOT 또는 SHOULD NOT이라고 한 일을 수행했을 때 생기는 security 영향은 매우 미묘할 수 있습니다. 대부분의 implementer는 specification을 만든 경험과 논의 과정을 직접 겪지 않았으므로, 문서 작성자는 권고나 requirement를 따르지 않았을 때의 security implication을 충분히 설명해야 합니다.
Security 문서 갱신
이 문서는 계속 갱신되는 living document입니다. 새로운 requirement, feature, change가 확인되면 다음 process를 거쳐 추가합니다.
- 관심 있는 party가 Zephyr documentation repository에 pull request로 change를 제출합니다.
- Zephyr Security Subcommittee가 change를 review하고 feedback을 주거나 승인합니다.
- 승인된 change는 문서의 일부가 됩니다.
현재 Security 정의
이 절은 Zephyr RTOS의 secure development 현황을 요약합니다. 현재는 functional security와 code quality assurance에 집중하고 있으며, 추가 security feature도 범위에 포함해 검토하고 있습니다.
현재 구현된 세 가지 주요 security measure는 다음과 같습니다.
- Security Functionality: Cryptographic algorithm과 protocol에 중점을 둡니다. Cryptographic hardware 지원은 향후 release 범위에 포함됩니다. Zephyr runtime architecture는 monolithic binary이므로 dynamic loader가 필요 없고, 그만큼 외부에 노출되는 attack surface가 줄어듭니다.
- Quality Assurance: 모든 code를 공용 repository에 반영하기 전에 반드시 review하게 하는 개발 process가 중심입니다. 검증된 network stack 같은 building block을 재사용하면 전체 quality level이 높아지고 안정적인 API를 제공할 수 있습니다. Static code analysis도 추가 quality check를 제공합니다.
- Execution Protection: Thread separation, stack protection, memory protection을 포함합니다. Upstream Zephyr RTOS는 1.9.0부터 stack protection을 제공했습니다. Memory protection과 thread separation은 x86에서 1.10.0, ARM과 ARC에서 1.11.0에 추가됐습니다.
이어지는 하위 절에서 이 항목들을 더 자세히 설명합니다.
Security Functionality
Zephyr의 security functionality는 주로 cryptographic algorithm 제공과 monolithic system design에 기반합니다.
Cryptographic feature는 PSA Crypto를 통해 제공되며, 실제 구현으로 mbedTLS를 사용합니다. Application은 PSA Crypto API를 사용하므로 cryptographic operation을 표준화되고 안전한 방식으로 수행할 수 있습니다. PSA Crypto 구현체인 mbedTLS는 다양한 cryptographic algorithm을 지원해 여러 application requirement에 대응합니다.
Hardware와 software 형태의 vendor-specific cryptographic IP를 위한 API도 계획되어 있습니다. Secure Access Module(SAM), Trusted Platform Module(TPM), Trusted Execution Environment(TEE) 형태의 secure key storage가 여기에 포함됩니다.
Security architecture는 Zephyr kernel과 모든 application을 하나의 static binary로 compile하는 monolithic design을 기반으로 합니다. System call은 context switch가 필요 없는 function call로 구현됩니다. Static linking은 악성 code를 동적으로 load할 가능성을 없앱니다.
후속 release에서는 추가 보호 feature를 사용할 수 있습니다. Stack protection mechanism은 stack overrun을 막습니다. Thread separation을 사용하면 system을 privileged environment와 unprivileged environment로 나눌 수 있습니다. Memory protection은 memory와 peripheral address space 같은 system resource를 partition으로 나누고, 개별 thread 또는 thread group에 할당합니다. Stack, thread execution level, memory protection constraint는 context switch 시점에 강제됩니다.
Quality Assurance
Zephyr project는 자동화된 quality assurance process를 사용합니다. Mandatory code review, feature·issue management와 tracking, static code analysis를 모두 포함하는 것이 목표입니다.
Code review는 기록되며, repository에 반영하기 전에 voting system으로 강제됩니다. 최종 반영은 담당 subsystem maintainer가 수행합니다. Code review의 주요 목표는 다음과 같습니다.
- 구현이 올바르게 동작하는지 검증
- 기여된 source code의 가독성과 유지보수성 향상
- String function과 memory function을 적절하게 사용하는지 확인
- User input 검증
- Security 관련 code에 잠재적 문제가 있는지 review
현재 coding principle은 대체로 coding style과 convention에 초점을 둡니다. Functional correctness는 build system과 reviewer의 경험으로 확인합니다. 특히 security 관련 code에는 구체적이고 상세한 guideline을 개발자와 합의해 마련해야 합니다. 자세한 내용은 Secure Coding 문서를 참고합니다.
Static code analysis는 Zephyr code tree 전체에 정기적으로 실행합니다.
Bug와 issue의 tracking·management에는 GitHub를 사용합니다. ‘Survivability’라는 용어는 security issue categorization과 management 같은 선제적 security task를 포괄합니다. Vulnerability로 확인된 문제는 GitHub security advisory 안에서 관리합니다.
Static analysis가 찾아낸 issue를 non-issue로 판단해 닫으려면 더 엄격한 review가 필요합니다. Security process 교육을 받은 다른 사람 적어도 한 명이 non-issue 판단에 동의해야 합니다.
Security process를 더 자세히 개발하기 위해 security subcommittee가 구성됐으며, 이 문서도 그 process의 일부입니다.
Execution Protection
Execution protection은 다음 task로 분류할 수 있습니다.
- Memory separation: Memory를 region으로 나누고 각 region의 owner에 따라 attribute를 지정합니다. Thread는 자신이 control하는 region에만 접근할 수 있습니다.
- Stack protection: Stack guard는 stack overrun을 감지하고 trap하는 mechanism을 제공합니다. 각 thread는 자기 stack에만 접근할 수 있어야 합니다.
- Thread separation: 각 thread는 자기 memory resource에만 접근할 수 있어야 합니다. Scheduler가 thread를 실행할 때 그 thread가 소유한 memory resource만 접근 가능하게 합니다. Program flow protection과 그 밖의 tamper resistance measure는 현재 범위에 포함되지 않습니다.
System Level Security(Ecosystem 등)
System-level security는 매우 다양한 범주를 포함합니다. 대표적인 예는 다음과 같습니다.
- Secure boot와 trusted boot
- OTA(Over-the-Air) update
- 외부 communication
- Device authentication
- Board 내부 resource의 access control
- Flash update
- Secure storage
- Peripheral
- Root of trust
- Attack surface 축소
이 범주 중 일부는 서로 연결되어 있으며, application을 위한 완전한 solution을 만들려면 여러 요소가 함께 마련되어야 합니다.
Secure Development Process
Secure code 개발은 일정한 기준을 따라야 합니다. 이 기준은 software quality와 software security에 관련된 두 범주로 크게 나눌 수 있는 coding guideline과 개발 process를 포함합니다. System architecture 문서도 작성하고 이후 개발에 맞춰 최신 상태로 유지해야 합니다.
System Architecture

그림 2는 Zephyr system architecture의 high-level schematic입니다. Architecture를 OS 부분(kernel + OS Services)과 사용자별 부분(Application Services)으로 나눕니다. OS 부분에는 low-level platform-specific driver, I/O API의 generic implementation, file system, kernel-specific function과 cryptographic library가 들어 있습니다.
System architecture와 design choice를 설명하는 문서를 만들고, 이후 개발에 맞춰 최신 상태로 유지해야 합니다. 이 문서는 Zephyr OS의 base architecture와 주요 submodule 개요를 포함해야 합니다. 각 module마다 별도의 architecture 문서를 만들고 실제 구현과 비교해 평가해야 합니다. 이런 문서는 새 developer의 시작점이자 security architecture의 기반이 됩니다. 자세한 내용은 Zephyr subsystem documentation을 참고합니다.
Secure Coding
Zephyr 같은 open software system을 안전하게 설계하려면 정해진 design standard를 따라야 합니다. 이 standard는 Zephyr Project documentation의 Secure Coding 절에 포함되어 있습니다. SALT75는 security violation을 예방하고 영향을 제한하기 위한 다음의 널리 인정된 protection mechanism 원칙을 정의합니다.
- Open design: 널리 사용되는 system에서는 protection mechanism을 비밀로 유지할 수 없다는 원칙입니다. 비밀 custom security measure에 의존하지 말고 공개적으로 인정된 cryptographic algorithm과 잘 확립된 cryptographic library를 사용해야 합니다.
- Economy of mechanism: System의 기반 design을 가능한 한 단순하고 작게 유지해야 합니다. Zephyr에서는 modular code와 abstracted API로 이를 실현할 수 있습니다.
- Complete mediation: 모든 object와 process에 접근할 때마다 먼저 authentication을 거쳐야 합니다. 가능하면 access condition을 저장해 재사용하는 mechanism을 피해야 합니다.
- Fail-safe defaults: 기본 상태에서는 access를 제한하고, successful authentication처럼 system protection scheme이 정한 특정 condition에서만 허용합니다. Service 기본 설정도 최대 security를 제공하도록 선택해야 하며, 이는 ‘Secure by Default’ paradigm에 해당합니다.
- Separation of privilege: Access를 허용하려면 둘 이상의 condition을 만족해야 한다는 원칙입니다. Zephyr에서는 split key를 예로 들 수 있습니다.
- Least privilege: 각 user, program, thread에는 task 수행에 필요한 가장 작은 permission subset만 부여해야 합니다. 이 positive security model은 system attack surface를 최소화합니다.
- Least common mechanism: 꼭 필요하지 않다면 둘 이상의 user나 process가 mechanism을 공유하지 않아야 합니다. SALT75의 예처럼 function은 모든 user가 함께 쓰는 supervisor procedure보다 각 user가 실행하는 shared library로 구현하는 편이 좋습니다.
- Psychological acceptability: Developer가 security feature를 실제로 사용하고 올바르게 적용할 수 있도록 사용하기 쉽게 만들어야 합니다.
이 일반 원칙 외에 secure RTOS 개발에는 다음 항목이 특별히 중요합니다.
- Complementary Security / Defense in Depth: 하나의 threat mitigation 방식에만 의존하지 않습니다. Complementary security에서는 기반 platform이 mitigation 일부를 담당합니다. Platform이 그런 mechanism을 제공하지 않거나 신뢰할 수 없다면 defense in depth를 사용해야 합니다.
- 자주 사용하지 않는 service는 기본 비활성화: 잠재적 attack 노출을 줄이기 위해 드물게 쓰는 feature나 service를 기본으로 켜지 않아야 합니다. MS12는 80% threshold를 제시합니다. Zephyr에서는 configuration management로 이를 구현할 수 있습니다. 각 functionality와 module을 configuration option으로 나타내고 명시적으로 enable하게 해야 합니다. 특정 use case에 필요 없는 feature, protocol, driver는 모두 disable할 수 있습니다. Low-level option이나 API를 enable했지만 application이 사용하지 않으면 user에게 알려야 합니다.
- Change management: System change를 추적할 수 있도록 모든 change는 change request, impact analysis, ratification, implementation, validation 단계로 이루어진 정해진 process를 따라야 합니다. 각 단계에 적절한 documentation을 제공해야 합니다. 모든 commit은 issue tracker의 bug report나 change request와 연결되어야 하며, 유효한 reference가 없는 commit은 거부해야 합니다.
이 design principle과 널리 인정된 best practice를 바탕으로 secure development guide를 개발·공개하고 Zephyr 개발 process에 적용해야 합니다. 자세한 내용은 아래 Secure Design 절에서 설명합니다.
Quality Assurance
Quality assurance는 다음 기준을 포함합니다.
- Coding Convention 준수: Coding style과 module·function·variable 등의 naming scheme을 지킵니다. 이는 Zephyr codebase의 가독성을 높이고 code review를 쉽게 합니다. Check-in 전에 automated script로 convention을 강제합니다.
- Deployment Guideline 준수: Feature set이 잘 문서화되고 security issue 목록을 추적할 수 있는 일관된 release를 보장하기 위해 필요합니다.
- Code Review: Codebase의 functional correctness를 보장하며 제안된 모든 code change를 check-in 전에 review해야 합니다. 작성자 외의 독립적인 reviewer가 적어도 한 명 참여해야 합니다. Subsystem maintainer와 developer가 functional level에서 수행하며, Secure Design 절의 security review와는 구분됩니다.
- Static Code Analysis: 큰 codebase에서 흔한 coding mistake를 효율적으로 찾습니다. Main repository에 merge하기 전에 모든 code를 적절한 tool로 분석해야 합니다. 개별 commit마다 실행하는 것은 아니며 특정 branch에 일정 간격으로 실행합니다. 각 release 전에 모든 finding을 제거하거나 false positive waiver를 승인해야 합니다. Waiver는 중앙 문서와 source code comment 양쪽에 기록합니다. 사용한 tool과 version, 분석 date, branch와 parent revision, waiver 사유, code author, waiver approver를 포함해야 합니다. 최소한 main release branch와 security branch에서 실행하며, release마다 waiver를 포함해 static analysis issue가 0개임을 보장해야 합니다.
- Complexity Analysis: 개발 process의 일부로 수행하고 cyclomatic complexity 같은 metric을 평가해야 합니다. 핵심 목표는 code를 가능한 한 단순하게 유지하는 것입니다.
- Automation: Review process와 coding rule 준수 check는 mandatory precommit check입니다. 일관되게 적용되도록 precommit procedure의 일부로 자동화해야 합니다. Subsystem에서 큰 code 묶음을 merge하기 전에는 review와 coding rule 검사뿐 아니라 모든 static code analysis를 실행하고 issue를 해결해야 합니다.
Release와 Lifecycle Management
Lifecycle management는 다음 여러 측면을 포함합니다.
- Device management: 현장에 배포된 Zephyr device의 operating system 또는 security 관련 subsystem을 update할 수 있어야 합니다.
- Lifecycle management: System stage와 stage 사이의 transition을 system state diagram으로 정의하고 문서화해야 합니다. Security를 위해 attack이 감지되면 device를 lock하는 단계와 end of life에 도달하면 종료하는 단계도 포함해야 합니다.
- Release management: Release cycle을 정의하고 release를 문서화하며 알려진 vulnerability와 mitigation 기록을 유지하는 process입니다. 특히 certification을 위해서는 backdoor 삽입 같은 사후 조작을 쉽게 탐지할 수 있도록 release integrity를 보장해야 합니다.
- Rights management와 NDA: 선택한 certification이 요구한다면 적절한 rights management, 예를 들어 별도 source repository와 관련 party 사이의 NDA로 system confidentiality와 integrity를 보장해야 합니다. 여러 party가 repository를 공유한다면 악성 code가 check-in되지 않도록 조치를 취해야 합니다.
이 항목들이 Zephyr project의 개발 process에 어떤 영향을 주는지 평가해야 합니다.
Secure Design
인증 가능한 system이나 product를 얻으려면 security process를 명확하게 정의하고, 적용 상태를 감시하며 이끌어야 합니다. 이 process는 security 관련 module의 모든 개발 단계와 보고된 security issue 관리를 포함합니다. 현재 알려진 attack vector와 미래 attack vector를 위한 threat model도 만들고, system에 미치는 영향을 조사해 완화해야 합니다. 자세한 내용은 Zephyr project의 Secure Coding 문서를 참고합니다.
Software security process는 다음을 포함합니다.
- Secure Development Coding 준수: 개별 component가 system security를 깨뜨리는 일을 방지하고 module별 vulnerability를 최소화하기 위해 의무적으로 지켜야 합니다. Automated test로 일부 확인할 수 있지만, security-critical module에서는 countermeasure 같은 security feature가 올바르게 구현됐는지 사람이 직접 조사해야 합니다.
- Security Review: Security를 목표로 하는 각 release를 준비할 때와 Zephyr project의 security 관련 module이 바뀔 때마다 security architect가 수행해야 합니다. 구현된 security measure의 effectiveness, global security strategy와 architecture 준수 여부를 검증하고, 필요하면 security certification audit를 준비합니다.
- Security Issue Management: 잠재적 system vulnerability를 평가하고 Security Issue Management process에 따라 완화합니다.
이 기준과 task를 secure software 개발 process에 통합하고 가능한 부분은 자동화해야 합니다. System level과 Zephyr secure branch의 각 security 관련 module에는 secure development process를 이끌 직접 책임 security architect를 지정해야 합니다.
Security Architecture
앞의 일반 guideline에는 system level과 module level의 architectural security design이 함께 따라야 합니다. High-level consideration은 다음과 같습니다.
- Security requirement와 compliance requirement 식별
- 적용 가능한 곳에서 cryptographic function을 사용하는 등의 functional security
- 알려진 attack vector에 대한 countermeasure 설계
- Security 관련 auditable event 기록
- Trusted Platform Module(TPM)과 Trusted Execution Environment(TEE) 지원
- Zephyr device를 현장에서 update할 수 있는 mechanism
- Task scheduler와 separation
Security architecture 개발은 전체 system architecture의 structural overview에서 도출한 asset을 기반으로 합니다. 개별 단계는 다음과 같습니다.
- User data, authentication key, encryption key, RNG에서 얻는 key generation data, security 관련 status information 같은 asset 식별
- Confidentiality 침해, user data 조작 등 asset을 향한 threat 식별
- Countermeasure나 memory protection scheme처럼 asset의 security와 protection에 필요한 requirement 정의
Security architecture를 기존 system architecture와 구현에 맞춰 조정해 deviation을 찾고 기존 weakness를 완화해야 합니다. Zephyr secure branch에 통합되는 새 submodule은 자체 security architecture를 설명하는 개별 문서를 제공해야 합니다. System-level security에 미치는 영향도 고려하고 문서화해야 합니다.
Security Vulnerability 보고
Security vulnerability 보고 방법은 Security Vulnerability Reporting 문서를 참고합니다.
Threat Modeling과 Mitigation
Zephyr RTOS에 대한 security threat modeling은 정확한 security architecture를 개발하고 대부분의 certification scheme을 따르는 데 필요합니다. 첫 단계는 system이 보호할 asset을 정의하는 것입니다. 다음으로 system이 이 asset을 어떻게 보호하는지, 어떤 threat가 존재하는지를 modeling합니다. Threat를 식별하면 해당 threat model을 만듭니다. Model에는 asset과 system의 vulnerability, 그리고 이 vulnerability를 이용할 수 있는 exploit 설명이 들어갑니다. Asset, asset이 위치한 module, 전체 system에 미치는 영향도 추정해야 합니다. 그 뒤 이 threat model을 module과 system security architecture에 반영하고, threat를 완화하거나 exploit 영향을 제한할 적절한 countermeasure를 정의합니다.
요약하면 OWASP에서 가져온 threat modeling process는 다음 단계로 나눌 수 있습니다.
- Asset 정의
- Application 분해와 적절한 DFD(Data Flow Diagram) 작성
- STRIDE와 CVSS 접근법을 사용한 threat 식별·분류
- Countermeasure와 다른 mitigation 방식 결정
이 절차는 module design 단계와 module 또는 system architecture를 크게 변경하기 전에 수행해야 합니다. 새로운 vulnerability나 exploit이 발견될 때마다 새 model을 만들거나 기존 model을 갱신해야 합니다. Security review에서는 담당 security architect가 threat model과 mitigation technique을 평가해야 합니다.
Threat model과 mitigation technique에서 countermeasure effectiveness를 입증할 test를 도출해야 합니다. 이 test를 continuous integration workflow에 통합해 regression 때문에 security가 약해지지 않도록 합니다.
Vulnerability Analysis
Software 구현의 약점을 찾기 위해 vulnerability analysis(VA)를 수행해야 합니다. Cryptographic algorithm, 중요한 OS task, connectivity protocol이 특히 중요한 조사 대상입니다.
순수 software level에서는 다음을 포함합니다.
- Penetration testing: 특정 hardware platform에서 RTOS를 시험하며, 해당 Zephyr OS configuration과 hardware를 하나의 system으로 다룹니다.
- Side-channel attack: Timing invariance와 power invariance 등을 고려해야 합니다. 예를 들어 cryptographic algorithm과 module의 timing invariance를 보장해 attack surface를 줄여야 합니다. Software 구현과 cryptographic hardware 사용 양쪽에 모두 적용됩니다.
- Fuzzing test: 외부에 노출된 API와 protocol 양쪽에 수행해야 합니다.
이 목록은 주로 설명을 위한 예입니다. 각 module과 완전한 Zephyr system, 일반적으로는 특정 hardware platform을 대상으로 적절한 VA plan을 만들고 실행해야 합니다. 분석에서 나온 finding은 security issue management process에 반영하고, 얻은 교훈을 guideline으로 정리해 secure coding guide에 포함해야 합니다.
Fuzzing analysis처럼 가능한 test는 continuous integration process에 통합해야 합니다.
Security Certification
Zephyr RTOS secure branch를 만드는 목표 중 하나는 인증 가능한 system 또는 인증 가능한 submodule을 제공하는 것입니다. Certification scope와 scheme은 아직 결정되지 않았습니다. 그러나 Common Criteria 같은 많은 certification은 evaluation claim이 실제로 충족됐다는 evidence를 요구하므로, 아래에서 일반적인 certification process를 설명합니다. 최종 certification scheme과 evaluation level을 선택한 뒤에는 이 process를 더 구체화해야 합니다.
일반 Certification Process
일반적인 certification 또는 precertification 단계는 다음과 같습니다.
- Zephyr RTOS 안에서 보호할 asset 정의. Cryptographic key 같은 confidential information, communication log 같은 user data, vendor나 manufacturer의 IP가 후보입니다.
- System vulnerability exploit로부터 asset을 보호할 threat model과 security architecture 개발. 완전한 threat model은 hardware platform까지 포함한 전체 product를 다루므로, 미리 인증된 Zephyr secure branch와 vendor가 인증할 Zephyr product로 나눈 split model로 구현할 수 있습니다.
- Asset security에 관한 certification claim과 operating condition에 대한 assumption을 포함하는 evaluation target 작성.
- Claim을 충족한다는 proof 제공. Security development process 전체를 일관되게 문서화하는 작업 등이 포함됩니다.
이 단계는 앞 절과 일부 겹칩니다. 다만 certification process에서는 certification 대상 component만 고려하면 됩니다. 예를 들어 security architecture는 system level asset 전체를 고려하므로 certification과 무관한 항목도 포함할 수 있습니다.
Certification 선택지
Security certification은 다음 방식 중 하나로 추진할 수 있습니다.
- Pure software system인 Zephyr의 abstract precertification: 기반 hardware platform과 Zephyr 위에서 실행할 최종 application에 관한 assumption이 필요합니다. Hardware와 application이 이 assumption을 충족하면 full certification을 더 쉽게 얻을 수 있습니다. 가장 유연하지만 product vendor의 부담이 가장 큽니다.
- 특정 application을 정하지 않고 특정 hardware platform의 Zephyr를 인증: Zephyr RTOS를 실행하는 secure platform을 제공하는 시나리오입니다. Hardware manufacturer가 application에 관한 정해진 assumption 아래 platform을 인증합니다. 최종 application이 assumption을 충족하면 적은 노력으로 product를 인증할 수 있습니다.
- 실제 product 인증: 특정 hardware, Zephyr RTOS, application을 포함하는 완전한 product를 인증합니다.
세 경우 모두 FIPS 140-2나 Common Criteria 같은 certification scheme, mainline Zephyr·security branch·특정 module 중 어디까지 인증할지 정하는 scope, certification 또는 assurance level을 결정해야 합니다.
부분 certification인 1번과 2번에서는 hardware 또는 software에 대한 assumption이 필요합니다. 예시는 다음과 같습니다.
- Hardware platform과 그 environment에 적절한 physical security가 있음
- Hardware platform 자체와 연결된 모든 device가 storage channel과 timing channel을 충분히 보호함. 원문은 remote connection을 언급하지 않습니다.
- Device에서는 trusted 또는 assured application만 실행됨
- 악의가 없고 적절히 교육받은 신뢰할 수 있는 사람이 device와 software stack을 configuration하고 운영함
이 assumption은 security claim과 evaluation target 문서에 포함해야 합니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.