C and C++ Binaries


MISC.MEM.PROT : メモリ保護の無効化

要旨

メモリ保護を無効化する入力引数が関数に渡されています。

プロパティ

クラス名 Memory Protection Removal
日本語クラス名 メモリ保護の無効化
クラス分類 セキュリティ (security)
ニーモニック MISC.MEM.PROT
カテゴリー
OWASP-2017 OWASP-2017:A6 Security misconfiguration
OWASP-2021 OWASP-2021:A5 Security misconfiguration
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Memory Protection Removal"

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/mman.h>

int map_memory (int infd, void *mybuf)
{
    char *src, *dst;
    struct stat statbuf;

    if (fstat (infd, &statbuf) < 0) return -1;
    src = mmap (mybuf,  /* Memory Protection Removal warning issued here */
                statbuf.st_size, 
                PROT_READ | PROT_WRITE | PROT_EXEC, 
                MAP_SHARED, 
                infd, 
                0);
    if (src == MAP_FAILED) return -1;
    exit(0);
}

ワーニングを引き起こす関数

CodeSonar ships with library models that allow it to functions such as libc mmap() and Win32 VirtualAlloc() that can set memory permission. If one of these functions is called with a problematic value in the relevant parameter position, a warning will be issued.

If you have created a custom library model for some function f() in terms of one of these existing models, calls to f() will also be capable of triggering Memory Protection Removal warnings.

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。