sdoc - guide to adding security considerations sections to manual pages
The guidelines for writing Fx manual pages in groff_mdoc7 mandate that each manual page describing a feature of the Fx system should contain a security considerations section describing what security requirements can be broken through the misuse of that feature. When writing these sections, authors should attempt to achieve a happy medium between two conflicting goals: brevity and completeness. On one hand, security consideration sections must not be too verbose, or busy readers might be dissuaded from reading them. On the other hand, security consideration sections must not be incomplete, or they will fail in their purpose of instructing the reader on how to avoid all insecure uses. This document provides guidelines for balancing brevity and completeness in the security consideration section for a given feature of the Fx system.
A good security considerations section should explain how the feature can be misused to violate each general security requirement in the list. Each explanation should be accompanied by instructions the reader should follow in order to avoid a violation. When referencing potential vulnerabilities described in the Secure Programming Practices manual page, sprog(7), likewise cross-reference that document rather than replicating information. Whenever possible, refer to this document rather than reproducing the material it contains.
Due to the need for brevity, security consideration sections should describe only those issues directly related to the feature that is the subject of the manual page. Refer to other manual pages rather than duplicating the material found there.
This is an example security considerations section for the strcpy(3) manual page:
The
strcpy ();
function is easily misused in a manner which enables malicious users
to arbitrarily change a running program's functionality
through a buffer overflow attack.
Avoid using
strcpy (.);
Instead, use
strncpy ();
and ensure that no more characters are copied to the destination buffer
than it can hold.
Do not forget to NUL-terminate the destination buffer,
as
strncpy ();
will not terminate the destination string if it is truncated.
Note that
strncpy ();
can also be problematic.
It may be a security concern for a string to be truncated at all.
Since the truncated string will not be as long as the original,
it may refer to a completely different resource
and usage of the truncated resource
could result in very incorrect behavior.
Example:
void foo(const char *arbitrary_string) { char onstack[8]; #if defined(BAD) /* * This first strcpy is bad behavior. Do not use strcpy()! */ (void)strcpy(onstack, arbitrary_string); /* BAD! */ #elif defined(BETTER) /* * The following two lines demonstrate better use of * strncpy(). */ (void)strncpy(onstack, arbitrary_string, sizeof(onstack) - 1); onstack[sizeof(onstack - 1)] = '\0'; #elif defined(BEST) /* * These lines are even more robust due to testing for * truncation. */ if (strlen(arbitrary_string) + 1 > sizeof(onstack)) err(1, "onstack would be truncated"); (void)strncpy(onstack, arbitrary_string, sizeof(onstack)); #endif }
Security considerations sections for tools and commands are apt to be less formulaic. Let your list of potentially-violated security requirements be your guide; explain each one and list a solution in as concise a manner as possible.
This is an example security considerations section for the rtld(1) manual page:
Using the LD_LIBRARY_PATH and LD_PRELOAD environment variables, malicious users can cause the dynamic linker to link shared libraries of their own devising into the address space of processes running non-set-user-ID/group-ID programs. These shared libraries can arbitrarily change the functionality of the program by replacing calls to standard library functions with calls to their own. Although this feature is disabled for set-user-ID and set-group-ID programs, it can still be used to create Trojan horses in other programs.
All users should be aware that the correct operation of non set-user-ID/group-ID dynamically-linked programs depends on the proper configuration of these environment variables, and take care to avoid actions that might set them to values which would cause the run-time linker to link in shared libraries of unknown pedigree.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |