CWE-1389 详情

CWE-1389

Incorrect Parsing of Numbers with Different Radices
2022-10-13
00h00 +00:00
Incomplete
2026-10-28
00h00 +00:00
指定 CWE 通知
随时了解指定 CWE 的变更。
管理通知

名称: Incorrect Parsing of Numbers with Different Radices

The product parses numeric input assuming base 10 (decimal) values, but it does not account for inputs that use a different base number (radix).

基本信息

背景详情

引入方式

Implementation : Input validation used may assume decimal bases during conditional checks, when it may not always be the case.
Implementation : The application may rely on a service that supports different numerical bases.

适用平台

编程语言

类: Not Language-Specific (Undetermined)
名称: Python (Undetermined)

技术

类: Not Technology-Specific (Undetermined)

常见后果

影响范围 影响 可能性
ConfidentialityRead Application Data

注意: An attacker may use an unexpected numerical base to access private application resources.
Unknown
IntegrityBypass Protection Mechanism, Alter Execution Logic

注意: An attacker may use an unexpected numerical base to bypass or manipulate access control mechanisms.
Unknown

观察示例

参考资料 描述

CVE-2021-29662

Chain: Use of zero-prepended IP addresses in Perl-based IP validation module can lead to an access control bypass.

CVE-2021-28918

Chain: Use of zero-prepended IP addresses in a product that manages IP blocks can lead to an SSRF.

CVE-2021-29921

Chain: Use of zero-prepended IP addresses in a Python standard library package can lead to an SSRF.

CVE-2021-29923

Chain: Use of zero-prepended IP addresses in the net Golang library can lead to an access control bypass.

CVE-2021-29424

Chain: Use of zero-prepended IP addresses in Perl netmask module allows bypass of IP-based access control.

CVE-2016-4029

Chain: incorrect validation of intended decimal-based IP address format (CWE-1286) enables parsing of octal or hexadecimal formats (CWE-1389), allowing bypass of an SSRF protection mechanism (CWE-918).

CVE-2020-13776

Mishandling of hex-valued usernames leads to unexpected decimal conversion and privilege escalation in the systemd Linux suite.

潜在缓解措施

Phases : Implementation
If only decimal-based values are expected in the application, conditional checks should be created in a way that prevent octal or hexadecimal strings from being checked. This can be achieved by converting any numerical string to an explicit base-10 integer prior to the conditional check, to prevent octal or hex values from ever being checked against the condition.
Phases : Implementation
If various numerical bases do need to be supported, check for leading values indicating the non-decimal base you wish to support (such as 0x for hex) and convert the numeric strings to integers of the respective base. Reject any other alternative-base string that is not intentionally supported by the application.
Phases : Implementation
If regular expressions are used to validate IP addresses, ensure that they are bounded using ^ and $ to prevent base-prepended IP addresses from being matched.

检测方法

Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

漏洞映射说明

依据 : This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
备注 : Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.

参考资料

REF-1284

Universal "netmask" npm package, used by 270,000+ projects, vulnerable to octal input data
Sick Codes.
https://sick.codes/universal-netmask-npm-package-used-by-270000-projects-vulnerable-to-octal-input-data-server-side-request-forgery-remote-file-inclusion-local-file-inclusion-and-more-cve-2021-28918/

提交记录

名称 组织 日期 发布日期 Version
Anonymous External Contributor 2021-05-28 +00:00 2022-10-13 +00:00 4.9

修改记录

名称 组织 日期 备注
CWE Content Team MITRE 2023-04-27 +00:00 updated Relationships, Time_of_Introduction
CWE Content Team MITRE 2023-06-29 +00:00 updated Mapping_Notes
CWE Content Team MITRE 2025-12-11 +00:00 updated Detection_Factors, Weakness_Ordinalities
CWE Content Team MITRE 2026-10-28 +00:00 updated Applicable_Platforms, Background_Details, Demonstrative_Examples, Description