使用MindIE时,为保证安全,用户应根据自身业务,审视整个系统的网络安全加固措施,按照所在组织的安全策略进行相关配置,包括但不局限于软件版本、口令复杂度要求、安全配置(协议、加密套件、密钥长度等),权限配置、防火墙设置等。关于更多安全声明与建议可参考昇腾社区MindIE安全管理与加固,以社区最新版本为准。
- 为减少潜在的安全风险,建议使用非root、非管理员类型账户执行系统操作,确保只有root才是系统的最高权限用户,确保系统中各系统账号的UID不同,遵循权限最小化原则。
- 定期开展对集群的防病毒扫描,防病毒例行检查会帮助集群免受病毒、恶意代码、间谍软件以及程序侵害,降低系统瘫痪、信息泄露等风险。可以使用业界主流防病毒软件进行防病毒检查。
- 为保证生产环境的安全,降低被攻击的风险,请定期查看昇腾社区MindIE安全管理与加固修复漏洞/功能问题。
- 建议用户将主机(包括宿主机)和容器中的umask设置为0027及以上,提高安全性。
- 建议用户对个人隐私数据、商业资产、业务开发相关的各类包含敏感内容的文件做好访问权限控制。例如本项目中安装目录权限管控、数据文件权限管控,设定的权限可参考A-文件(夹)各场景权限管控推荐最大值。
- 禁止使用SetUID或SetGID等特殊权限的shell脚本。
- 禁止使用高危capability的可执行文件。
- 系统中不允许存在无属主的文件。
-
本项目需要自行编译构建出包,编译过程会产生一些中间文件和编译目录,建议用户对这些文件做好权限控制,在构建过程中可根据需要修改构建脚本以避免相关安全风险,并注意构建结果安全。
-
本项目涉及Python whl包安装,为避免其他用户直接访问和修改Python代码引起代码篡改、伪造等风险,建议用户设置Python为仅安装用户可修改和使用。
-
使用Linux自带的ASLR(Address Space Layout Randomization)和KASLR(Kernel Address Space Layout Randomization)机制进行安全编译。
-
ASLR,开启后可以增强漏洞攻击防护能力,开启方式为:
```shell echo 2 > /proc/sys/kernel/randomize_va_space ``` -
KASLR,开启后可以增加针对内核漏洞的攻击难度,开启方式如下所示:
-
使用以下示例命令查看内核配置文件。
vi /boot/config-$(uname -r)如果存在以下行则表示支持KASLR。
CONFIG_RANDOMIZE_BASE=y
-
打开配置文件/etc/default/grub,在GRUB_CMDLINE_LINUX_DEFAULT所在行添加kaslr参数,示例如下所示。
GRUB_CMDLINE_LINUX_DEFAULT="kaslr" -
使用以下命令更新grub配置。
sudo update-grub
-
使用以下命令重启系统后即开启KASLR功能。
sudo reboot
-
-
-
为阻止缓冲区溢出攻击,建议使用ASLR技术,通过对堆、栈、共享库映射等线性区布局的随机化,增加攻击者预测目的地址的难度,防止攻击者直接定位攻击代码位置。该技术可作用于堆、栈、内存映射区(mmap基址、shared libraries、vdso页)。
-
确保当前用户拥有“/proc/sys/kernel/randomize_va_space”文件的写权限。
-
开启缓冲区溢出安全保护。
echo 2 >/proc/sys/kernel/randomize_va_space
-
- 本项目会涉及到接收输入、加载模型权重和保存结果数据,部分接口直接或间接使用风险模块pickle,可能存在数据风险,请确保输入数据来源、保存路径地址可信,加载模型权重时,建议使用本地权重。
- 为避免服务和客户端通信过程信息泄露,建议用户启用HTTPS通信并启用双向认证,如果启用,建议对通信认证涉及的证书、私钥、口令等做好安全访问控制。
- MindIE仅提供部分流控能力,且不直接对接公网,建议用户对MindIE流控和公网、局域网隔离做好控制。如可以使用开源软件Nginx进行保障,用户可参照Nginx官方文档和昇腾社区Server安全加固进行Nginx的部署。
- 对于全网侦听的端口和其他端口,如非必要建议关闭。
- 建议用户关闭不安全的服务,如Telnet、FTP等。
- 用户可以根据自身业务,按IP地址限制与服务器的连接速率对系统进行防DoS攻击,方法包括但不限于利用Linux系统自带iptables防火墙进行预防、优化sysctl参数等。
- 本项目默认的Gloo、DataDist和HCCL通信暂不支持TLS认证功能,如有需要,可参考B-集合通信加固。
本项目提供的对外接口均已在资料中公开,建议直接使用资料说明的公开接口,不建议直接调用未明确公开的接口源码。
本项目的通信矩阵,包括产品开放的端口、该端口使用的传输层协议、通过该端口与对端通信的通信网元名称、认证方式、用途等信息说明均已在资料中公开,可参考昇腾社区MindIE通信矩阵,以社区最新版本为准。
本项目代码中包含的公网地址声明均已在资料中公开,可参考昇腾社区MindIE公网URL,以社区最新版本为准。
-
本项目仅供调试和开发之用,使用者需自行承担使用风险,并理解以下内容:
- 数据处理及删除:用户在使用本项目过程中产生的数据(包括但不限于推理结果、日志等)属于用户责任范畴。建议用户在使用完毕后及时删除相关数据,以防泄露或不必要的信息泄露。
- 数据保密与传播:使用者了解并同意不得将通过本项目产生的数据随意外发或传播。对于由此产生的信息泄露、数据泄露或其他不良后果,本项目及其开发者概不负责。
- 用户输入安全性:用户需自行保证输入的命令行、参数和配置文件的安全性,并承担因输入不当而导致的任何安全风险或损失。对于由于输入不当所导致的问题,本项目及其开发者概不负责。
-
免责声明范围:本免责声明适用于所有使用本项目的个人或实体。使用本项目即表示您同意并接受本声明的内容,并愿意承担因使用该功能而产生的风险和责任,如有异议请停止使用本项目。
-
在使用本项目之前,请谨慎阅读并理解以上免责声明的内容。对于使用本项目所产生的任何问题或疑问,请及时联系开发者。
| 类型 | Linux权限参考最大值 |
|---|---|
| 用户主目录 | 750(rwxr-x---) |
| 程序文件(含脚本文件、库文件等) | 550(r-xr-x---) |
| 程序文件目录 | 550(r-xr-x---) |
| 配置文件 | 640(rw-r-----) |
| 配置文件目录 | 750(rwxr-x---) |
| 日志文件(记录完毕或者已经归档) | 440(r--r-----) |
| 日志文件(正在记录) | 640(rw-r-----) |
| 日志文件目录 | 750(rwxr-x---) |
| Debug文件 | 640(rw-r-----) |
| Debug文件目录 | 750(rwxr-x---) |
| 临时文件目录 | 750(rwxr-x---) |
| 维护升级文件目录 | 770(rwxrwx---) |
| 业务数据文件 | 640(rw-r-----) |
| 业务数据文件目录 | 750(rwxr-x---) |
| 密钥组件、私钥、证书、密文文件目录 | 700(rwx-----) |
| 密钥组件、私钥、证书、加密密文 | 600(rw-------) |
| 加解密接口、加解密脚本 | 500(r-x------) |
编译和支持安装TLS的PyTorch的操作步骤如下。
-
步骤1 编译PyTorch
-
安装openssl-1.1
wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz tar -xzf openssl-1.1.1w.tar.gz cd openssl-1.1.1w ./config --prefix=/usr/local/openssl-1.1 make -j$(nproc) sudo make install cd ..
-
获取PyTorch源码(克隆仓库并初始化子模块)。
git clone https://github.com/pytorch/pytorch.git --depth=1 -b v2.9.0 cd pytorch git submodule sync && git submodule update --init --depth=1 --recursive
-
导出环境变量
export OPENSSL_ROOT_DIR=/usr/local/openssl-1.1 export LD_LIBRARY_PATH=$OPENSSL_ROOT_DIR/lib:$LD_LIBRARY_PATH export USE_GLOO=1 export USE_GLOO_WITH_OPENSSL=1
-
构建Python包
python3 setup.py bdist_wheel
-
-
步骤2 安装PyTorch。支持TLS需要安装torch 2.1.0a0+git7bcf7da版本。
cd dist pip install --ignore-installed torch-2.1.0a0+git7bcf7da-cp311-cp311-linux_aarch.whl -
步骤3 编译安装Gloo
git config --global http.sslVerify false git clone https://github.com/pytorch/gloo.git mkdir build && cd build cmake .. -DUSE_TCP_OPENSSL_LOAD=ON make -j$(nproc) sudo make install export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
-
步骤4 开启GLOO TLS
export GLOO_DEVICE_TRANSPORT=TCP_TLS export GLOO_DEVICE_TRANSPORT_TCP_TLS_PKEY=/path/to/tls_ca/server.key.pem export GLOO_DEVICE_TRANSPORT_TCP_TLS_CERT=/path/to/tls_ca/server.pem export GLOO_DEVICE_TRANSPORT_TCP_TLS_CA_FILE=/path/to/tls_ca/ca.pem
When using MindIE, users must review the cybersecurity hardening measures of the entire system according to their business needs and configure the system in accordance with their organization's security policies. This includes, but is not limited to, software versions, password-complexity requirements, security settings such as protocols, cipher suites and key lengths, permission settings, and firewall rules. For additional statements and recommendations, see MindIE Security Management and Hardening. The latest community documentation prevails.
- To reduce potential security risks, use a non-root, non-administrator account
for system operations. Ensure that only
roothas the highest system privileges, that system accounts have distinct UIDs, and that the principle of least privilege is followed. - Regularly scan the cluster for viruses. Routine antivirus checks help protect the cluster from viruses, malicious code, spyware, service disruption, and information leakage. Use a reputable antivirus product appropriate for the deployment environment.
- To protect production environments and reduce exposure, regularly consult MindIE Security Management and Hardening for vulnerability and functional-issue remediation guidance.
- Set
umaskto0027or a more restrictive value on hosts, including host systems and containers. - Apply access controls to files containing personal data, commercial assets, development materials, or other sensitive content. For this project, this includes installation directories and data files. See Appendix A for recommended maximum permissions.
- Do not use shell scripts with SetUID or SetGID permissions.
- Do not use executable files with high-risk capabilities.
- Do not allow ownerless files to remain in the system.
-
This project is built from source. The build process creates intermediate files and build directories. Apply appropriate permissions to those files, adjust build scripts where necessary to avoid security risks, and protect the resulting artifacts.
-
This project installs Python wheel packages. To reduce the risk of code tampering or forgery by other users, configure Python so that only the installing user can modify and use the installation.
-
Use Linux ASLR (Address Space Layout Randomization) and KASLR (Kernel Address Space Layout Randomization) mechanisms for secure builds.
-
To enable ASLR and improve protection against exploit attacks, run:
echo 2 > /proc/sys/kernel/randomize_va_space
-
To enable KASLR:
-
Inspect the kernel configuration:
vi /boot/config-$(uname -r)The following line indicates KASLR support:
CONFIG_RANDOMIZE_BASE=y -
Add the
kaslrparameter to theGRUB_CMDLINE_LINUX_DEFAULTline in/etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT="kaslr" -
Update the GRUB configuration:
sudo update-grub
-
Restart the system:
sudo reboot
-
-
-
To mitigate buffer-overflow attacks, enable ASLR to randomize the layout of the heap, stack, shared-library mappings,
mmapbase address, and VDSO pages.-
Ensure that the current user can write to
/proc/sys/kernel/randomize_va_space. -
Enable the protection:
echo 2 >/proc/sys/kernel/randomize_va_space
-
This project accepts input, loads model weights, and saves result data. Some
interfaces directly or indirectly use the high-risk pickle module. Ensure
that input data and output paths are trusted, and prefer local model weights.
- To prevent information leakage during server-client communication, enable HTTPS and mutual authentication. Protect the certificates, private keys, and passwords used for communication authentication.
- MindIE provides limited traffic-control capabilities and must not be exposed directly to the public network. Protect MindIE through traffic controls and network isolation. For example, deploy Nginx according to the Nginx documentation and Ascend Server Security Hardening.
- Close ports that listen on all network interfaces, and close other ports that are not required.
- Disable insecure services such as Telnet and FTP.
- Restrict connection rates by IP address to reduce denial-of-service risks.
Possible controls include Linux
iptablesrules and hardenedsysctlparameters. - The default Gloo, DataDist, and HCCL communication mechanisms used by this project do not currently support TLS authentication. If TLS is required, see Appendix B.
All supported public interfaces are documented. Use the documented public APIs and avoid directly calling source interfaces that are not explicitly public.
The project communication matrix documents exposed ports, transport protocols, peer network elements, authentication methods, and intended uses. See the MindIE Communication Matrix. The latest community documentation prevails.
Public network addresses contained in the project source are documented in MindIE Public URLs. The latest community documentation prevails.
See the Ascend community Vulnerability Management Policy. Do not disclose suspected vulnerabilities in a public Issue before following that policy's reporting and coordination process.
-
This project is provided for debugging and development. Users assume the risks of use and acknowledge the following:
- Data handling and deletion: Data generated during use, including inference results and logs, is the user's responsibility. Delete data promptly after use to prevent unintended disclosure.
- Data confidentiality and distribution: Do not distribute data generated by this project without appropriate authorization. The project and its developers are not responsible for disclosure or other consequences caused by unauthorized distribution.
- Input security: Users are responsible for the safety of command-line input, parameters, and configuration files, and assume risks or losses caused by unsafe input.
-
This disclaimer applies to every person or entity using the project. By using the project, you accept these terms and the associated risks. Stop using the project if you do not agree.
-
Read and understand this disclaimer before using the project. Contact the maintainers if you have questions.
| Type | Recommended maximum Linux permission |
|---|---|
| User home directory | 750 (rwxr-x---) |
| Program file, including scripts and libraries | 550 (r-xr-x---) |
| Program directory | 550 (r-xr-x---) |
| Configuration file | 640 (rw-r-----) |
| Configuration directory | 750 (rwxr-x---) |
| Completed or archived log file | 440 (r--r-----) |
| Active log file | 640 (rw-r-----) |
| Log directory | 750 (rwxr-x---) |
| Debug file | 640 (rw-r-----) |
| Debug directory | 750 (rwxr-x---) |
| Temporary-file directory | 750 (rwxr-x---) |
| Maintenance and upgrade directory | 770 (rwxrwx---) |
| Business data file | 640 (rw-r-----) |
| Business data directory | 750 (rwxr-x---) |
| Directory containing key components, private keys, certificates, or ciphertext | 700 (rwx------) |
| Key component, private key, certificate, or encrypted file | 600 (rw-------) |
| Encryption/decryption interface or script | 500 (r-x------) |
The following procedure builds a PyTorch package with TLS support.
-
Build PyTorch.
-
Install OpenSSL 1.1:
wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz tar -xzf openssl-1.1.1w.tar.gz cd openssl-1.1.1w ./config --prefix=/usr/local/openssl-1.1 make -j$(nproc) sudo make install cd ..
-
Clone the PyTorch source and initialize its submodules:
git clone https://github.com/pytorch/pytorch.git --depth=1 -b v2.9.0 cd pytorch git submodule sync && git submodule update --init --depth=1 --recursive
-
Export the environment variables:
export OPENSSL_ROOT_DIR=/usr/local/openssl-1.1 export LD_LIBRARY_PATH=$OPENSSL_ROOT_DIR/lib:$LD_LIBRARY_PATH export USE_GLOO=1 export USE_GLOO_WITH_OPENSSL=1
-
Build the Python package:
python3 setup.py bdist_wheel
-
-
Install PyTorch. TLS support requires
torch 2.1.0a0+git7bcf7da:cd dist pip install --ignore-installed torch-2.1.0a0+git7bcf7da-cp311-cp311-linux_aarch.whl -
Build and install Gloo:
git config --global http.sslVerify false git clone https://github.com/pytorch/gloo.git mkdir build && cd build cmake .. -DUSE_TCP_OPENSSL_LOAD=ON make -j$(nproc) sudo make install export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
-
Enable Gloo TLS:
export GLOO_DEVICE_TRANSPORT=TCP_TLS export GLOO_DEVICE_TRANSPORT_TCP_TLS_PKEY=/path/to/tls_ca/server.key.pem export GLOO_DEVICE_TRANSPORT_TCP_TLS_CERT=/path/to/tls_ca/server.pem export GLOO_DEVICE_TRANSPORT_TCP_TLS_CA_FILE=/path/to/tls_ca/ca.pem