CWE-453 不安全的缺省变量初始化

admin 2021年12月12日05:46:56评论74 views字数 1814阅读6分2秒阅读模式

CWE-453 不安全的缺省变量初始化

Insecure Default Variable Initialization

结构: Simple

Abstraction: Variant

状态: Draft

被利用可能性: unkown

基本描述

The software, by default, initializes an internal variable with an insecure or less secure value than is possible.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 1188 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 1188 cwe_View_ID: 699 cwe_Ordinal: Primary

适用平台

Language: [{'cwe_Name': 'PHP', 'cwe_Prevalence': 'Sometimes'}, {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}]

常见的影响

范围 影响 注释
Integrity Modify Application Data An attacker could gain access to and modify sensitive data or system information.

可能的缓解方案

System Configuration

策略:

Disable or change default settings when they can be used to abuse the system. Since those default settings are shipped with the product they are likely to be known by a potential attacker who is familiar with the product. For instance, default credentials should be changed or the associated accounts should be disabled.

示例代码

This code attempts to login a user using credentials from a POST request:

bad PHP


// $user and $pass automatically set from POST request

if (login_user($user,$pass)) {

$authorized = true;

}
...

if ($authorized) {

generatePage();

}

Because the $authorized variable is never initialized, PHP will automatically set $authorized to any value included in the POST request if register_globals is enabled. An attacker can send a POST request with an unexpected third value 'authorized' set to 'true' and gain authorized status without supplying valid credentials.

Here is a fixed version:

bad PHP

$user = $_POST['user'];
$pass = $_POST['pass'];
$authorized = false;
if (login_user($user,$pass)) {

$authorized = true;

}
...

This code avoids the issue by initializing the $authorized variable to false and explicitly retrieving the login credentials from the $_POST variable. Regardless, register_globals should never be enabled and is disabled by default in current versions of PHP.

Notes

分类映射

映射的分类名 ImNode ID Fit Mapped Node Name
PLOVER Insecure default variable initialization

文章来源于互联网:scap中文网

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月12日05:46:56
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CWE-453 不安全的缺省变量初始化https://cn-sec.com/archives/613264.html

发表评论

匿名网友 填写信息