提交 67366b73 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!11 add security design guild

Merge pull request !11 from LV/master
# MindSpore Open Source Security Design Guide
This document is developed based on industry standards, open source best practices, and MindSpore service development trends to guide developers in module design and avoid high security design risks.
## 1. Identification and Authentication
1.1 All machine-to-machine interfaces for cross-network transmission must have an access authentication mechanism, and the authentication process must be performed on a server.
**Notice**: Cross-network interfaces must support identity authentication to prevent spoofing access.
1.2 For each access request that requires authorization, the server must verify whether the user is authorized to perform this operation.
**Notice**: Unauthorized URL access is a typical web security vulnerability. Attackers can easily bypass the system permission control to access system resources and use system functions without authorization. To prevent users from directly entering a URL to request and execute some pages without authorization, the background needs to authenticate the permission of the user who requests the URL.
1.3 The server must validate the size, type, length, and special characters of all untrusted data sources and reject any data that fails the validation.
**Notice**: To prevent attackers from intercepting and tampering with requests through a proxy to bypass the validity check of the client, data validation must be performed on the server.
1.4 Functions that allow access to the system or data while bypassing the system security mechanism (such as authentication, permission control, and log recording) are prohibited.
**Notice**: If a product has functions that allow access to the system or data without the system security mechanism, malicious personnel may be aware of the functions and perform operations without authorization, which greatly affects the system.
1.5 According to the principle of least privilege, accounts used to run software programs are low-privilege OS accounts.
**Notice**: Privileged accounts such as root, administrator, and supervisor or high-level accounts cannot be used to run software programs. Instead, use common accounts to run software programs.
## 2. Secure Transmission
2.1 Sensitive data (including passwords, batch images, and voice data) or key service data (network structure, model parameters, and gradient data) must be transmitted across networks using secure transmission protocols or encrypted before transmission.
**Notice**: When data is transmitted across networks, it is vulnerable to theft or tampering by attackers. Therefore, important data must be protected.
2.2 Do not use SSL2.0, SSL3.0, TLS1.0, or TLS1.1 for secure transmission. TLS1.2 and TLS1.3 are recommended.
**Notice**: Secure Sockets Layer (SSL) 2.0 and SSL 3.0 have been disabled by Internet Engineering Task Force (IETF) in March 2011 and June 2015 due to security issues. In Transport Layer Security (TLS) 1.0, the symmetric encryption algorithm supports only the RC4 algorithm and the cipher block chaining (CBC) mode of the block cipher algorithm. RC4 algorithm is regarded as insecure and is disabled by IETF in all TLS versions. The CBC mode of the symmetric encryption algorithm has the problem of predictable initialization vector (IV) and is vulnerable to BEAST attacks. Therefore, TLS 1.2 and TLS 1.3 are recommended.
## 3. Sensitive and Private Data Protection
3.1 Authentication credentials (such as passwords and keys) cannot be stored in plaintext in the system and must be encrypted. If plaintext does not need to be restored, use the irreversible PBKDF2 algorithm for encryption. If plaintext needs to be restored, you can use the AES-256 GCM algorithm for encryption.
3.2 By default, personal data of a data subject cannot be not directly read. If necessary, provide an interface to obtain data subjects' authorization.
**Notice**: Personal data belongs to data subjects. If personal data needs to be accessed and collected, data subjects' consent and authorization are required.
3.3 By default, data generated during training and inference cannot be transferred to a third party. If necessary, provide an interface to obtain data subjects' authorization.
**Notice**: Before transferring personal data of data subjects to a third party, provide a reasonable method to notify the data subjects of the types of personal data to be transferred, transfer purposes, and information about the data recipients, and obtain the consent of the data subjects.
3.4 If personal data needs to be used for marketing, user profiling, and market survey, provide an interface to obtain data subjects' authorization and provide an interface for data subjects to withdraw their authorization at any time.
**Notice**: If personal data is used for user profiling and marketing, explicit user authorization must be obtained so that users can choose whether to use their personal data for basic services. Products or systems sold to the EU, if involving user profiling and marketing, must inform users of the user profiling logic, consequences of rejecting to provide personal data, and whether personal data is transferred out of European Economic Area (EEA), apart from informing them of their right to reject.
## 4. Encryption Algorithm and Key Management
4.1 Do not use proprietary and non-standard cryptographic algorithms.
**Notice**: Proprietary and non-standard cryptographic algorithms cannot be used in products. On the one hand, it is difficult to ensure the security strength of cryptographic algorithms designed by non-cryptography professionals. On the other hand, such algorithms are not analyzed and validated in the industry, and may have unknown defects. In addition, such design violates the open and transparent security design principles. It is recommended that common open-source password components in the industry, such as OpenSSL and OpenSSH, be used.
4.2 Do not use insecure cryptographic algorithms. Strong cryptographic algorithms are recommended.
**Notice**: With the development of cryptographic technologies and improvement of computing capabilities, some cryptographic algorithms no longer apply to the current security field, such as insecure symmetric encryption algorithms DES and RC4, insecure asymmetric encryption algorithm RSA-1024, insecure hash algorithms SHA-0, SHA-1, MD2, MD4, and MD5, and insecure key negotiation algorithms DH-1024. Instead, AES-256, RSA-3072, SHA-256, PBKDF2, or stronger cryptographic algorithms are recommended.
4.3 Keys used to encrypt data cannot be hard-coded.
**Notice**: Keys must be replaceable to prevent disclosure risks caused by long-term use.
4.4 Use cryptographically secure random numbers for security purposes.
**Notice**: Random numbers are used for cryptographic algorithm purposes, such as the generation of IVs, salts, and keys. Insecure random numbers make keys and IVs partially or entirely predictable. Cryptographically secure random numbers must be unpredictable.
4.5 Use a secure random number generator to generate keys.
**Notice**: If the key is generated by a random number generator, the random number generator must be secure. If an insecure random number generator is used, the obtained keys may be predicted. For example, you can use RAND_bytes in the OpenSSL library, /dev/random device interface in the Linux OS, and the RNG in the Trusted Platform Module (TPM).
## 5. Security Document
5.1 All public function interfaces, RESTful interfaces, local function interfaces, command line interfaces, and default usernames and passwords used for identity authentication must be described in the low-level design (LLD) document.
**Notice**: All the preceding new interfaces must be described in the LLD document to help users better understand the corresponding modules.
5.2 External communication connections are necessary for system running and maintenance. All communication ports used must be described in the LLD document. Dynamic listening ports must be limited to a proper range.
**Notice**: If external communication ports are not described in the LLD document, user security configuration may be affected.
# MindSpore开源安全设计指南
本规范主要参考业界广泛标准和开源最佳实践,结合MindSpore业务发展趋势,制定出MindSpore开源安全设计指南,用于指导开发者进行模块设计,避免出现高安全设计风险。
## 1. 身份认证&鉴权
1.1 所有跨网络传输的机机接口需要有接入认证机制, 且认证处理过程应放到服务端进行。
**说明**:跨网络接口需要支持身份认证避免攻击者仿冒接入。
1.2 应在服务器端对于每一个需要授权访问的请求核实用户身份是否被授权执行这个操作。
**说明**:URL越权是典型的Web安全漏洞,利用该漏洞,攻击者可以很轻易地绕过系统的权限控制,未经授权地访问系统资源、使用系统的功能。为防止用户通过直接输入URL,越权请求并执行一些页面,在请求某一URL时,后台需对请求该URL的用户进行权限鉴定。
1.3 在服务器端对所有来自不可信数据源进行大小、类型、长度、以及特殊字符等合法性校验,拒绝任何没有通过校验的数据。
**说明**:避免攻击者通过代理拦截并篡改请求绕过客户端的合法性校验,所以需要在服务端进行数据校验。
1.4 不应存在可绕过系统安全机制(认证、权限控制、日志记录)对系统或数据进行访问的功能。
**说明**:产品若存在可绕过系统安全机制对系统或数据进行访问的功能,有可能被恶意人员知晓进行私自操作,从而给系统造成很大影响。
1.5 根据权限最小化原则,运行软件程序的帐号要尽可能的使用操作系统低权限的帐号。
**说明**:对于运行软件程序的操作系统帐号,不应使用“root”、“administrator”、“supervisor”等特权帐号或高级别权限帐号,应该使用普通权限的账号运行。
## 2. 安全传输
2.1 在跨网络之间进行敏感数据(包括口令,批量图片、语音等个人数据)或关键业务数据(网络结构、模型参数、梯度数据)传输应采用安全传输协议或者加密后传输。
**说明**:在跨网络进行传输时,容易遭受攻击者窃取或篡改,需要对重要数据进行保护。
2.2 不应使用SSL2.0、SSL3.0、TLS1.0、TLS1.1协议进行安全传输,推荐使用更安全协议TLS1.2和TLS1.3。
**说明**:SSL2.0和SSL3.0协议因存在很多安全问题已分别于2011年3月和2015年6月被IETF禁用。TLS1.0协议中对称加密算法仅支持RC4算法和分组加密算法的CBC模式,RC4已经公认不安全并被IETF在TLS所有版本协议中禁用,而对称算法的CBC模式存在IV可预测的问题,从而容易受到BEAST攻击。因此,推荐使用TLS1.2和TLS1.3协议。
## 3. 敏感/隐私数据保护
3.1 认证凭据(如口令、密钥等)不允许明文存储在系统中,应该加密保护,在不需要还原明文的场景,应使用不可逆PBKDF2算法加密,如果需要还原,则可以使用AES-256 GCM算法加密。
3.2 默认不应直接读取数据主体的个人数据,如果需要,则要提供相应接口获得数据主体授权。
**说明**:个人数据都属于数据主体,如果需要访问和收集,需要获取数据主体同意并授权。
3.3 默认不应对训练和推理过程中的数据转移给第三方,如果需要,则要提供相应接口获得数据主体授权。
**说明**:在将数据主体的个人数据提供给第三方前,需提供合理方式告知数据主体转移的个人数据类型、转移目的以及数据接收方的相关信息,并获得数据主体的同意。
3.4 如果要将个人数据用于营销、用户画像、市场调查,则要提供相应接口获得数据主体授权,并提供数据主体随时撤销授权的接口。
**说明**:如果使用个人数据进行用户画像和营销时,需要获取获取用户明示授权,让用户自由选择是否同意将自己的个人数据用于提供基本服务。在欧盟,涉及用户画像和营销时,除了要告知用户有否决权,而且需要告知用户个人数据是否转出EEA、用户画像的逻辑、拒绝提供个人数据的后果。
## 4. 加密算法&密钥管理
4.1 不应使用私有的、非标准的密码算法。
**说明**:私有的、非标准的密码算法不应该在产品中使用。一方面,非密码学专业人员设计的密码算法,其安全强度难以保证。另一方面,这类算法在技术上也未经业界分析验证,有可能存在未知的缺陷,并且这样的设计违背公开透明的安全设计原则,推荐使用业界常用的开源密码组件,如OpenSSL、OpenSSH等。
4.2 不应使用不安全的密码算法,推荐使用强密码算法。
**说明**:随着密码技术的发展以及计算能力的提升,一些密码算法已不再适合现今的安全领域,如不安全对称加密算法DES、RC4等,不安全非对称加密算法RSA 1024等,不安全哈希算法SHA-0、SHA-1、MD2、MD4、MD5等,不安全密钥协商DH-1024等,推荐使用AES-256、RSA-3072、SHA-256、PBKDF2或更强密码算法。
4.3 用于对数据进行加密的密钥不能在代码中硬编码。
**说明**:密钥要支持替换,避免长期使用增加被泄露风险。
4.4 密码算法中使用到的随机数应是密码学意义上的安全随机数。
**说明**:随机数用于生成IV、盐值、密钥等,都属于密码算法用途。不安全的随机数使得密钥、IV等可被全部或部分预测。密码学意义上的安全随机数,要求必须保证其不可预测性。
4.5 用于产生密钥的随机数发生器应使用安全随机数发生器。
**说明**:如果密钥是通过随机数发生器来产生的,则该随机数发生器必须是安全的随机数发生器。使用不安全的随机数发生器来产生密钥,可能会使得到的密钥存在被预测的风险。例如可以使用: OpenSSL库的RAND_bytes、Linux操作系统的/dev/random设备接口、TPM中的随机数产生器(RNG)模块。
## 5. 安全资料
5.1 所有新增跨网络通信的公开函数接口、RESTful接口、本地函数接口、命令行接口、以及身份认证使用到的默认用户/口令都必须在详细设计文档中说明。
**说明**:所有上面列举的新增接口都要在详细设计文档中说明,以便更好的理解相应的模块。
5.2 对外通信连接必须是系统运行和维护必需,对使用到的所有通信端口需要在详细设计文档中说明,动态侦听端口必须限定合理范围。
**说明**:若对外通信端口不在文档中说明,则可能会影响用户安全配置。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册