| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Security</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" /> |
| 10 | <link rel="up" href="env.html" title="Chapter 9. The Berkeley DB Environment" /> |
| 11 | <link rel="prev" href="env_region.html" title="Shared memory regions" /> |
| 12 | <link rel="next" href="env_encrypt.html" title="Encryption" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Security</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="env_region.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 9. |
| 26 | The Berkeley DB Environment |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="env_encrypt.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="env_security"></a>Security</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p>The following are security issues that should be considered when writing |
| 42 | Berkeley DB applications:</p> |
| 43 | <div class="variablelist"> |
| 44 | <dl> |
| 45 | <dt> |
| 46 | <span class="term">Database environment permissions</span> |
| 47 | </dt> |
| 48 | <dd>The directory used as the Berkeley DB database environment should have its |
| 49 | permissions set to ensure that files in the environment are not accessible |
| 50 | to users without appropriate permissions. Applications that add to the |
| 51 | user's permissions (for example, UNIX setuid or setgid applications), |
| 52 | must be carefully checked to not permit illegal use of those permissions |
| 53 | such as general file access in the environment directory.</dd> |
| 54 | <dt> |
| 55 | <span class="term">Environment variables</span> |
| 56 | </dt> |
| 57 | <dd>Setting the <a href="../api_reference/C/envopen.html#envopen_DB_USE_ENVIRON" class="olink">DB_USE_ENVIRON</a> |
| 58 | and <a href="../api_reference/C/envopen.html#envopen_DB_USE_ENVIRON_ROOT" class="olink">DB_USE_ENVIRON_ROOT</a> flags |
| 59 | and allowing the use of environment variables during file naming can be |
| 60 | dangerous. Setting those flags in Berkeley DB applications with additional |
| 61 | permissions (for example, UNIX setuid or setgid applications) could |
| 62 | potentially allow users to read and write databases to which they would |
| 63 | not normally have access.</dd> |
| 64 | <dt> |
| 65 | <span class="term">File permissions</span> |
| 66 | </dt> |
| 67 | <dd>By default, Berkeley DB always creates files readable and writable by the owner |
| 68 | and the group (that is, S_IRUSR, S_IWUSR, S_IRGRP and S_IWGRP; or octal mode |
| 69 | 0660 on historic UNIX systems). The group ownership of created files is |
| 70 | based on the system and directory defaults, and is not further specified |
| 71 | by Berkeley DB.</dd> |
| 72 | <dt> |
| 73 | <span class="term">Temporary backing files</span> |
| 74 | </dt> |
| 75 | <dd>If an unnamed database is created and the cache is too small to hold |
| 76 | the database in memory, Berkeley DB will create a temporary physical file to |
| 77 | enable it to page the database to disk as needed. In this case, |
| 78 | environment variables such as <span class="bold"><strong>TMPDIR</strong></span> may be used to specify |
| 79 | the location of that temporary file. Although temporary backing files |
| 80 | are created readable and writable by the owner only (S_IRUSR and |
| 81 | S_IWUSR, or octal mode 0600 on historic UNIX systems), some filesystems |
| 82 | may not sufficiently protect temporary files created in random |
| 83 | directories from improper access. To be absolutely safe, applications |
| 84 | storing sensitive data in unnamed databases should use the |
| 85 | <a href="../api_reference/C/envset_tmp_dir.html" class="olink">DB_ENV->set_tmp_dir()</a> method to specify a temporary directory with |
| 86 | known permissions.</dd> |
| 87 | <dt> |
| 88 | <span class="term">Tcl API</span> |
| 89 | </dt> |
| 90 | <dd>The Berkeley DB Tcl API does not attempt to avoid evaluating input as Tcl |
| 91 | commands. For this reason, it may be dangerous to pass unreviewed user |
| 92 | input through the Berkeley DB Tcl API, as the input may subsequently be |
| 93 | evaluated as a Tcl command. Additionally, the Berkeley DB Tcl API |
| 94 | initialization routine resets process' effective user and group IDs to |
| 95 | the real user and group IDs, to minimize the effectiveness of a Tcl |
| 96 | injection attack.</dd> |
| 97 | </dl> |
| 98 | </div> |
| 99 | </div> |
| 100 | <div class="navfooter"> |
| 101 | <hr /> |
| 102 | <table width="100%" summary="Navigation footer"> |
| 103 | <tr> |
| 104 | <td width="40%" align="left"><a accesskey="p" href="env_region.html">Prev</a> </td> |
| 105 | <td width="20%" align="center"> |
| 106 | <a accesskey="u" href="env.html">Up</a> |
| 107 | </td> |
| 108 | <td width="40%" align="right"> <a accesskey="n" href="env_encrypt.html">Next</a></td> |
| 109 | </tr> |
| 110 | <tr> |
| 111 | <td width="40%" align="left" valign="top">Shared memory regions </td> |
| 112 | <td width="20%" align="center"> |
| 113 | <a accesskey="h" href="index.html">Home</a> |
| 114 | </td> |
| 115 | <td width="40%" align="right" valign="top"> Encryption</td> |
| 116 | </tr> |
| 117 | </table> |
| 118 | </div> |
| 119 | </body> |
| 120 | </html> |