SDOC(7)
πΈ SDOC(7) β the bestie guide to security considerations sections π
okay so this is SDOC(7) from the Miscellaneous Information Manual, and it's literally your roadmap for writing security considerations sections in manual pages. no cap, it's giving "how to not be the person who ships insecure docs." β¨
π NAME π
sdoc β guide to adding security considerations sections to manual pages
π¦ DESCRIPTION π¦
okay so here's the whole deal, bestie. This doc hands you the guidelines for adding security considerations sections to manual pages, and it gives you two typical examples so you can see it in action. π«Ά
The guidelines for writing FreeBSD manual pages in groff_mdoc(7) mandate that every manual page describing a feature of the FreeBSD system should contain a security considerations section. and what goes in it? a description of what security requirements can be broken through the misuse of that feature. simple as that. π
When you're writing these sections, you gotta hit a happy medium between two conflicting goals: brevity and completeness. like, on one hand, security consideration sections must not be too verbose, or busy readers might get dissuaded from reading them π. on the other hand, they must not be incomplete, or they'll fail in their purpose of instructing the reader on how to avoid all insecure uses. so this document is literally here to give you guidelines for balancing brevity and completeness in the security consideration section for a given feature of the FreeBSD system. slay. β¨
π§ Where to Start π§
Begin by listing those general security requirements that can be violated through the misuse of the feature. There are four classes of security requirements:
- integrity β example: non-administrators should not modify system binaries
- confidentiality β example: non-administrators should not view the shadow password file
- availability β example: the web server should respond to client requests in a timely fashion
- correctness β example: the
psprogram should provide exactly the process table information listing functionality described in its documentation β no more, no less.
A good security considerations section should explain how the feature can be misused to violate each general security requirement in the list. and every single explanation should be accompanied by instructions the reader should follow in order to avoid a violation. π
When you're referencing potential vulnerabilities described in the Secure Programming Practices manual page, sprog(7), likewise cross-reference that document rather than replicating information. and whenever possible, refer to this document rather than reproducing the material it contains. iykyk. π
π Where to Stop π
Security problems are often interrelated β individual problems often have far-reaching implications. like, for example, the correctness of virtually any dynamically-linked program is dependent on the correct implementation and configuration of the run-time linker. and the correctness of this program, in turn, depends on the correctness of its libraries, the compiler used to build it, the correctness of the preceding compiler that was used to build that compiler, and so on, as described by Thompson (see "SEE ALSO", below). it's turtles all the way down fr fr. π’
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. don't be out here copy-pasting, bestie. π
π₯ EXAMPLES π₯
Security considerations sections for most individual functions can follow this simple formula:
- Provide one or two sentences describing each potential security problem.
- Provide one or two sentences describing how to avoid each potential security problem.
- Provide a short example in code.
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.
π SEE ALSO π
groff_mdoc(7), security(7), sprog(7)
Edward Amoroso, AT&T Bell Laboratories, Fundamentals of Computer Security Technology, P T R Prentice Hall, 1994.
Ken Thompson, "Reflections on Trusting Trust", Association for Computing Machinery, Inc., Communications of the ACM, Vol. 27, No. 8, 761-763, August, 1984.
π HISTORY π
The sdoc manual page first appeared in FreeBSD 5.0. vintage icon behavior. π
β AUTHORS β
Tim Fraser <tfraser@tislabs.com>, NAI Labs CBOSS project Brian Feldman <bfeldman@tislabs.com>, NAI Labs CBOSS project
and that's the whole page, bestie! this one's from the Debian world, dated September 5, 2005 β shoutout to the manpage archive for keeping the lore alive πβ¨π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2001, 2002 Networks Associates Technology, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms