Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: FIO04 compliance

...

Code Block
bgColor#ccccff
#include <sys/resource.h>
/* ... */
struct rlimit limit;
char *secret;

limit.rlim_cur = 0;
limit.rlim_max = 0;
if (setrlimit(RLIMIT_CORE, &limit) != 0) {
    /* Handle Error */
}

/* Create or otherwise obtain some sensitive data */
if (fgets(secret, sizeof(secret), stdin);) == EOF) {
  /* Handle Error */
}

Compliant Solution (privileged process on UNIX)

...

Code Block
bgColor#CCCCFF
#include <sys/resource.h>
/* ... */
struct rlimit limit;
char *secret;

limit.rlim_cur = 0;
limit.rlim_max = 0;
if (setrlimit(RLIMIT_CORE, &limit) != 0) {
    /* Handle Error */
}

if (mlock(secret, sizeof(secret)) != 0) {
    /* Handle error */
}

/* Create or otherwise obtain some sensitive data */
if (fgets(secret, sizeof(secret), stdin); == EOF) {
  /* Handle Error */
}

Compliant Solution (privileged process on Windows)

Code Block
bgColor#CCCCFF
char *secret;

if (VirtualLock(secret, sizeof(secret)) != 0) {
    /* Handle error */
}

/* Create or otherwise obtain some sensitive data */
if (fgets(secret, sizeof(secret), stdin); == EOF) {
  /* Handle Error */
}

Risk Assessment

Writing sensitive data to disk preserves it for future retrieval by an attacker, who may even be able to bypass the access restrictions of the operating system by using a disk maintenance program.

...