Part 1
요약·해설
8대 보호 원칙, RTOS 추가 원칙과 Security Subcommittee 책임을 설명합니다.
8 protection principles
Secure designer · Vulnerability expert
Review · Tracking · Consensus
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
83675672BFC6C77F03B2859E0F85FCDD35F5C8FA7578FB1CC12B6A818209C8A9
.. _secure code:
Secure Coding
#############
Traditionally, microcontroller-based systems have not placed much
emphasis on security.
They have usually been thought of as isolated, disconnected
from the world, and not very vulnerable, just because of the
difficulty in accessing them. The Internet of Things has changed
this. Now, code running on small microcontrollers often has access to
the internet, or at least to other devices (that may themselves have
vulnerabilities). Given the volume they are often deployed at,
uncontrolled access can be devastating [#attackf]_.
This document describes the requirements and process for ensuring
security is addressed within the Zephyr project. All code submitted
should comply with these principles.
Much of this document comes from [CIIBPB]_.
Introduction and Scope
**********************
This document covers guidelines for the `Zephyr Project`_, from a
security perspective. Many of the ideas contained herein are captured
from other open source efforts.
.. todo: Reference main document here
.. _Zephyr Project: https://www.zephyrproject.org/
We begin with an overview of secure design as it relates to
Zephyr. This is followed by
a section on `Secure development knowledge`_, which
gives basic requirements that a developer working on the project will
need to have. This section gives references to other security
documents, and full details of how to write secure software are beyond
the scope of this document. This section also describes
vulnerability knowledge that at least one of the primary developers
should have. This knowledge will be necessary for the review process
described below this.
Following this is a description of the review process used to
incorporate changes into the Zephyr codebase. This is followed by
documentation about how security-sensitive issues are handled by the
project.
Finally, the document covers how changes are to be made to this
document.
Secure Coding
*************
Designing an open software system such as Zephyr to be secure requires
adhering to a defined set of design standards. In [SALT75]_, the following,
widely accepted principles for protection mechanisms are defined to
help prevent security violations and limit their impact:
- **Open design** as a design guideline 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 their 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.
Secure development knowledge
****************************
Secure designer
===============
The Zephyr project must have at least one primary developer who knows
how to design secure software.
This requires understanding the following design principles,
including the 8 principles from [SALT75]_:
- economy of mechanism (keep the design as simple and small as
practical, e.g., by adopting sweeping simplifications)
- fail-safe defaults (access decisions shall deny by default, and
projects' installation shall be secure by default)
- complete mediation (every access that might be limited must be
checked for authority and be non-bypassable)
.. todo: Explain better the constraints of embedded devices, and that
we typically do edge detection, not at each function. Perhaps
relate this to input validation below.
- open design (security mechanisms should not depend on attacker
ignorance of its design, but instead on more easily protected and
changed information like keys and passwords)
- separation of privilege (ideally, access to important objects should
depend on more than one condition, so that defeating one protection
system won't enable complete access. For example, multi-factor
authentication, such as requiring both a password and a hardware
token, is stronger than single-factor authentication)
- least privilege (processes should operate with the least privilege
necessary)
- least common mechanism (the design should minimize the mechanisms
common to more than one user and depended on by all users, e.g.,
directories for temporary files)
- psychological acceptability (the human interface must be designed
for ease of use - designing for "least astonishment" can help)
- limited attack surface (the set of the
different points where an attacker can try to enter or extract data)
- input validation with whitelists (inputs should typically be checked
to determine if they are valid before they are accepted; this
validation should use whitelists (which only accept known-good
values), not blacklists (which attempt to list known-bad values)).
Vulnerability Knowledge
=======================
A "primary developer" in a project is anyone who is familiar with the
project's code base, is comfortable making changes to it, and is
acknowledged as such by most other participants in the project. A
primary developer would typically make a number of contributions over
the past year (via code, documentation, or answering questions).
Developers would typically be considered primary developers if they
initiated the project (and have not left the project more than three
years ago), have the option of receiving information on a private
vulnerability reporting channel (if there is one), can accept commits
on behalf of the project, or perform final releases of the project
software. If there is only one developer, that individual is the
primary developer.
At least one of the primary developers **must** know of common kinds of
errors that lead to vulnerabilities in this kind of software, as well
as at least one method to counter or mitigate each of them.
Examples (depending on the type of software) include SQL
injection, OS injection, classic buffer overflow, cross-site
scripting, missing authentication, and missing authorization. See the
`CWE/SANS top 25`_ or `OWASP Top 10`_ for commonly used lists.
A free class from the nonprofit OpenSecurityTraining2 for C/C++ developers
is available at `OST2_1001`_. It teaches how to prevent, detect, and
mitigate linear stack/heap buffer overflows, non-linear out of bound writes,
integer overflows, and other integer issues. The follow-on class, `OST2_1002`_,
covers uninitialized data access, race conditions, use-after-free, type confusion,
and information disclosure vulnerabilities.
.. Turn this into something specific. Can we find examples of
mistakes. Perhaps an example of things static analysis tool has sent us.
.. _CWE/SANS top 25: http://cwe.mitre.org/top25/
.. _OWASP Top 10: https://owasp.org/www-project-top-ten/
.. _OST2_1001: https://ost2.fyi/Vulns1001
.. _OST2_1002: https://ost2.fyi/Vulns1002
Zephyr Security Subcommittee
============================
There shall be a "Zephyr Security Subcommittee", responsible for
enforcing this guideline, monitoring reviews, and improving these
guidelines.
This team will be established according to the Zephyr Project charter.
Code Review
***********
The Zephyr project shall use a code review system that all changes are
required to go through. Each change shall be reviewed by at least one
primary developer that is not the author of the change. This
developer shall determine if this change affects the security of the
system (based on their general understanding of security), and if so,
shall request the developer with vulnerability knowledge, or the
secure designer to also review the code. Any of these individuals
shall have the ability to block the change from being merged into the
mainline code until the security issues have been addressed.
Issues and Bug Tracking
***********************
The Zephyr project shall have an issue tracking system (such as GitHub_)
that can be used to record and track defects that are found in the
system.
.. _GitHub: https://www.github.com
Because security issues are often sensitive, this issue tracking
system shall have a field to indicate a security issue. Setting this
field shall result in the issue only being visible to the Zephyr Security
Subcommittee. In addition, there shall be a
field to allow the Zephyr Security Subcommittee to add additional users that will
have visibility to a given issue.
This embargo, or limited visibility, shall only be for a fixed
duration, with a default being a project-decided value. However,
because security considerations are often external to the Zephyr
project itself, it may be necessary to increase this embargo time.
The time necessary shall be clearly annotated in the issue itself.
The list of issues shall be reviewed at least once a month by the
Zephyr Security Subcommittee. This review should focus on
tracking the fixes, determining if any external parties need to be
notified or involved, and determining when to lift the embargo on the
issue. The embargo should **not** be lifted via an automated means, but
the review team should avoid unnecessary delay in lifting issues that
have been resolved.
Modifications to This Document
******************************
Changes to this document shall be reviewed by the Zephyr Security Subcommittee,
and approved by consensus.
.. [#attackf] An attack_ resulted in a significant portion of DNS
infrastructure being taken down.
.. _attack: http://www.theverge.com/2016/10/21/13362354/dyn-dns-ddos-attack-cause-outage-status-explained
Part 3
한국어 전문 번역
전통적으로 microcontroller 기반 system은 security를 크게 강조하지 않았습니다. 외부와 격리되어 있고 접근하기 어렵다는 이유만으로 취약하지 않다고 여겨지는 경우가 많았습니다. 그러나 Internet of Things가 이를 바꿨습니다. 이제 작은 microcontroller에서 실행되는 code도 internet이나 vulnerability가 있을 수 있는 다른 device에 연결됩니다. 이런 device는 대량 배포되므로 통제되지 않은 접근은 막대한 피해를 일으킬 수 있습니다. 실제로 공격 하나가 DNS infrastructure의 상당 부분을 중단시킨 사례가 있습니다.
이 문서는 Zephyr project에서 security를 다루기 위한 requirement와 process를 설명합니다. 제출되는 모든 code는 이 원칙을 따라야 합니다. 내용의 상당 부분은 Core Infrastructure Initiative Best Practices Badge 자료에서 가져왔습니다.
소개와 범위
이 문서는 security 관점에서 Zephyr Project가 따라야 할 guideline을 다룹니다. 여러 idea는 다른 open source 활동에서 가져왔습니다.
먼저 Zephyr와 관련된 secure design을 개괄합니다. 이어지는 Secure development knowledge 절은 project developer에게 필요한 기본 지식을 설명합니다. 다른 security 문서를 안내하지만 secure software 작성법 전체는 이 문서 범위를 벗어납니다. Primary developer 중 적어도 한 명이 갖춰야 할 vulnerability 지식도 설명하며, 이 지식은 뒤에서 정의하는 review process에 필요합니다.
그다음 Zephyr codebase에 change를 반영하는 review process를 설명하고, project가 security-sensitive issue를 처리하는 방법을 다룹니다. 마지막으로 이 문서 자체를 변경하는 절차를 정합니다.
Secure Coding
Zephyr 같은 open software system을 안전하게 설계하려면 정의된 design standard를 따라야 합니다. Saltzer와 Schroeder가 제시한 널리 받아들여지는 보호 mechanism 원칙은 security violation을 예방하고 영향을 제한합니다.
- Open design: 널리 사용되는 system의 보호 mechanism을 비밀로 유지할 수 없다는 전제입니다. 비밀 custom security measure에 의존하지 않고 공개적으로 인정된 cryptographic algorithm과 검증된 cryptographic library를 사용해야 합니다.
- Economy of mechanism: System의 기반 design을 가능한 한 단순하고 작게 유지합니다. Zephyr에서는 modular code와 abstracted API로 구현할 수 있습니다.
- Complete mediation: 모든 object와 process에 접근할 때마다 먼저 authority를 확인해야 합니다. 가능하면 access condition을 cache하는 mechanism을 피합니다.
- Fail-safe defaults: 기본적으로 접근을 제한하고, successful authentication처럼 system protection scheme이 정한 특정 조건에서만 허용합니다. 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을 공유하지 않습니다. 예를 들어 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는 기본으로 켜지 않습니다. Microsoft 자료는 80% threshold를 예로 듭니다. Zephyr에서는 각 functionality와 module을 configuration option으로 만들고 명시적으로 활성화하게 합니다. 특정 use case에 필요 없는 feature, protocol과 driver를 모두 끌 수 있어야 하며, low-level option이나 API를 켜 놓고 application이 사용하지 않으면 user에게 알려야 합니다.
- Change management: System change의 traceability를 보장하도록 모든 change가 change request, impact analysis, ratification, implementation, validation 단계로 구성된 정해진 process를 따라야 합니다. 각 단계에 적절한 documentation을 제공하고 모든 commit을 issue tracker의 bug report나 change request와 연결해야 합니다. 유효한 reference가 없는 commit은 거부합니다.
Secure development knowledge
Secure designer
Zephyr project에는 secure software 설계 방법을 아는 primary developer가 최소 한 명 있어야 합니다.
이 developer는 Saltzer와 Schroeder의 8개 원칙을 포함해 다음 design principle을 이해해야 합니다.
- Economy of mechanism: 광범위한 단순화를 적용하는 등 design을 실용적으로 가능한 한 단순하고 작게 유지합니다.
- Fail-safe defaults: Access decision은 기본적으로 deny해야 하며 project installation도 기본 상태에서 안전해야 합니다.
- Complete mediation: 제한될 수 있는 모든 access는 authority를 확인하고 우회할 수 없어야 합니다. Embedded device에서는 일반적으로 모든 function 내부가 아니라 trust boundary edge에서 검사한다는 제약도 고려합니다.
- Open design: Security mechanism은 attacker가 design을 모른다는 사실에 의존하지 않고 key와 password처럼 더 쉽게 보호·교체할 수 있는 정보에 의존해야 합니다.
- Separation of privilege: 중요한 object 접근은 둘 이상의 condition에 의존하는 것이 바람직합니다. Password와 hardware token을 모두 요구하는 multi-factor authentication은 single-factor보다 강합니다.
- Least privilege: Process는 필요한 최소 privilege로 동작해야 합니다.
- Least common mechanism: Temporary file directory처럼 여러 user가 공통으로 사용하고 모두 의존하는 mechanism을 최소화해야 합니다.
- Psychological acceptability: Human interface는 쉽게 사용할 수 있어야 하며 least astonishment 원칙이 도움이 됩니다.
- Limited attack surface: Attacker가 진입하거나 data를 빼낼 수 있는 서로 다른 지점의 집합을 제한합니다.
- Whitelist 기반 input validation: Input을 수락하기 전에 유효한지 검사합니다. 알려진 bad value를 나열하는 blacklist 대신 알려진 good value만 허용하는 whitelist를 사용해야 합니다.
Vulnerability 지식
Project의 primary developer는 codebase에 익숙하고 change를 편하게 만들 수 있으며 대부분의 participant가 그렇게 인정하는 사람입니다. 보통 지난 1년 동안 code·documentation·질문 답변으로 여러 contribution을 한 developer를 뜻합니다.
Project를 시작했고 떠난 지 3년이 지나지 않았거나, private vulnerability reporting channel의 정보를 받을 수 있거나, project를 대신해 commit을 accept하거나 최종 software release를 수행할 수 있다면 일반적으로 primary developer로 봅니다. Developer가 한 명뿐이면 그 사람이 primary developer입니다.
Primary developer 중 최소 한 명은 이 종류의 software에서 vulnerability를 만드는 흔한 error와 각 error를 막거나 완화하는 방법을 하나 이상 반드시 알아야 합니다.
Software 종류에 따라 SQL injection, OS injection, classic buffer overflow, cross-site scripting, missing authentication과 missing authorization 등이 포함됩니다. 일반적인 목록은 CWE/SANS Top 25와 OWASP Top 10을 참고합니다.
Nonprofit OpenSecurityTraining2는 C/C++ developer용 무료 OST2_1001 class를 제공합니다. Linear stack/heap buffer overflow, non-linear out-of-bounds write, integer overflow와 기타 integer issue를 예방·탐지·완화하는 법을 가르칩니다. 후속 OST2_1002 class는 uninitialized data access, race condition, use-after-free, type confusion과 information disclosure vulnerability를 다룹니다.
Zephyr Security Subcommittee
이 guideline을 집행하고 review를 감시하며 guideline을 개선하는 Zephyr Security Subcommittee를 둬야 합니다. Team은 Zephyr Project charter에 따라 구성합니다.
Code Review
Zephyr project는 모든 change가 반드시 통과해야 하는 code review system을 사용합니다. 각 change는 작성자가 아닌 primary developer 한 명 이상이 review해야 합니다.
Reviewer는 일반적인 security 이해를 바탕으로 change가 system security에 영향을 주는지 판단합니다. 영향을 준다면 vulnerability 지식을 가진 developer나 secure designer에게 추가 review를 요청합니다. 이들은 security issue가 해결될 때까지 change가 mainline code에 merge되는 것을 block할 권한을 가져야 합니다.
Issue와 Bug Tracking
Zephyr project는 system에서 발견된 defect를 기록하고 추적할 GitHub 같은 issue tracking system을 갖춰야 합니다.
Security issue는 민감한 경우가 많으므로 tracking system에 security issue임을 나타내는 field가 있어야 합니다. 이 field를 설정하면 Zephyr Security Subcommittee만 issue를 볼 수 있어야 합니다. Subcommittee가 특정 issue를 볼 추가 user를 지정할 field도 있어야 합니다.
이 embargo 또는 limited visibility는 고정 기간에만 적용하며 기본값은 project가 정합니다. 다만 security consideration이 Zephyr project 외부와 연관되는 경우 embargo 기간을 늘려야 할 수 있습니다. 필요한 기간을 issue에 명확히 기록해야 합니다.
Zephyr Security Subcommittee는 issue 목록을 적어도 한 달에 한 번 검토해야 합니다. Fix 진행을 추적하고 외부 party에 알리거나 참여시켜야 하는지, 언제 embargo를 해제할지 판단하는 데 집중합니다. Embargo는 자동으로 해제하면 안 되지만 해결된 issue 공개를 불필요하게 지연해서도 안 됩니다.
이 문서의 수정
이 문서의 change는 Zephyr Security Subcommittee가 review하고 consensus로 승인해야 합니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.