Mac OS X Internals: A Systems Approach
2.14. Security
We could informally define computer security as a condition wherein all computer resources are always used "as intended." However, it is impossible to exhaustively enumerate all of one's intentions, which will differ in any case from one personor one scenarioto another.[76] We could express the notion of computer security in somewhat more concrete terms as follows: Security is the union of software, hardware, policies, and practices that allows a system and its users to achieve the following: [76] Surely, there could be situations that neither the designers of a system nor its users have thought of yet.
A definition of security could be reinforced by describing the absence of security, that is, insecurity. A computer system's resourcesincluding external, shared resources such as the networkare all vulnerable to attacks: from outside and often from within. We can think of a vulnerability as a potential for unintended usea result of a software bug, a design oversight or error, a misconfiguration, and so on. When exploited via attacks, vulnerabilities could lead to tangible or intangible damage. The following are examples of common types of potential damage:
A system's resources could be misused without denying service to legitimate users or without causing any apparent damage to the system itself. For example, if a system's resources are lying idle, it can still be misused as a stepping-stone to infiltrate another system.
Now that we have an informal understanding of computer security, let us look at important security-related aspects and features in Mac OS X. Figure 234 depicts many of these features. Figure 234. The Mac OS X security architecture
Figure 234 does not show some daemons that play security-related roles in the operating system. For example, lookupd caches and makes available a variety of information such as user accounts, groups, computer names, and printers. Another daemon, memberd, resolves group memberships and responds to membership API calls made by clients. Examples of these calls include mbr_uid_to_uuid() and mbr_uuid_to_id(). Mac OS X security features can be divided between those provided by the kernel-level and user-level security models. Additionally, a firmware password may be used on Apple computers in a potentially hardware- or model-dependent manner. We will look at Open Firmware password protection in Chapter 4. 2.14.1. Kernel-Space Security
The Mac OS X kernel security model consists of both Mac OS Xspecific and typical Unix-style features. The following are examples of the kernel's security-related features.
2.14.2. User-Space Security
Mac OS X provides a flexible user-space security model that is largely based on the Common Data Security Architecture (CDSA). CDSA is an open source security architecture adopted as a technical standard[77] by the Open Group. It consists of a cryptographic framework and several layers of security services. Apple uses its own CDSA implementation, which is depicted in Figure 234. [77] The CDSA Specification was initiated by Intel Architecture Labs. The current standard is a cooperative work of many organizations and companies, including Apple and IBM. CDSA helps in the implementation of security features such as encryption, fine-grained access permissions and user authentication, and secure data storage. 2.14.2.1. CDSA Plug-ins
The lowest layer of CDSA consists of plug-ins called by the layer above. CDSA plug-ins are allowed to call each other as well. Apple-provided CDSA plug-ins are shown in Figure 234. CDSA allows additional plug-ins to exist. 2.14.2.2. CSSM API
CDSA's core is a set of modules called the Common Security Services Manager (CSSM). The CSSM modules shown in the CSSM Managers block in Figure 234 together provide the CSSM API. The Authorization Computation Services Manager module shown within a dotted outline is not present in Apple's CDSA implementation. 2.14.2.3. Mac OS X Security APIs
Mac OS X applications normally use Apple's middleware security APIs that are built atop the CSSM API to access CDSA functionality. However, it is possible for an application to use the CSSM API directly. Examples of services provided by the middleware APIs include the following.
2.14.2.4. Security Server and Security Agent
As shown in Figure 234, Authorization Services communicate with the Security Server, which then uses the CDSA APIs. Besides authorization, the Authorization Services API also handles authentication if required.
Authorization involves asking whether a given entity is allowed to perform a given operation. Before the question may be answered, the requester is typically required to authenticatethat is, to prove his or her identity. Then it is determined whether the entity in question has the appropriate permissions. The Security Server[79] (/usr/sbin/securityd) acts as an arbiter of many types of security-related operations and accesses. For example, fine-grained authorization of arbitrary operations by applications is based on rules contained in the /etc/authorization policy database. The Authorization Services API includes functions to add, delete, edit, and read policy database items. When an application requests a rightfor example, com.osxbook.Test.DoSomething[80]it makes an authorization call. The call is routed to securityd, which consults the policy database. securityd attempts to find a rule that exactly matches the requested right. If none is found, securityd looks for wildcard rules that may match, in the order of the longest match first. If there are no matches at all, securityd uses the generic rule, which is used for rights that do not have any specific rules. If the user authenticates successfully, securityd creates a credential with an expiration period of 5 minutes.[81] [79] The Security Server is not part of CDSA. [80] Rules and rights are conventionally named in the policy database using a reverse DNS naming scheme. [81] The expiration period is specified through the timeout key in the policy database. The Security Agent application (/System/Library/CoreServices/SecurityAgent.app) is the user-interface handler for securitydthe latter does not interact with the user directly but launches Security Agent as a separate process, which in turn displays a username and password request dialog. Thus, Security Agent enforces GUI interaction, which normally warrants physical presence.[82] [82] Physical presence is warranted unless the system is being driven remotely through a product such as Apple Remote Desktop. Beginning with Mac OS X 10.4, an application can authorize a user by passing in a username and password to the authorization functionwithout displaying the authentication dialog box. 2.14.2.5. Using Authorization Services
Figure 235 shows a program that requests a right named com.osxbook.Test.DoSomething. If the right doesn't exist in the policy databasewhich should be the case when the program is run for the first timeit sets up the right based on an existing standard rule called kAuthorizationAuthenticateAsSessionUser. The latter requires the user to authenticate as the session ownerthat is, the currently logged-in user. Figure 235. Using Authorization Services
2.14.2.6. Miscellaneous Security-Related Features
Other Mac OS X security features readily available to end users, or otherwise controllable by them, include the following.
2.14.3. System Administration
Mac OS X can be effectively administered through either graphical user interfaces or the command line. Let us look at some examples of using the command line to control Mac OS Xspecific aspects of system administration. 2.14.3.1. Interacting with the Security Framework
The security command provides access to the functionality in the Security framework (Security.framework). In particular, it can be used to access and manipulate certificates, keys, keychains, and password items, as shown in Figure 236. Figure 236. Examining keychains using the security command
2.14.3.2. Interacting with Directory Services
The server version of Mac OS X uses the LDAP-based[83] Open Directory software to provide directory and authentication services for Mac OS X, Unix, and Windows clients. A directory service is simply a central repository for storing and vending information about users, computers, printers, and other network resources in an organization. Application and system software can access such information for a variety of purposes: authenticating logins, locating user home directories, enforcing resource quotas, controlling accesses to file systems, and so on. Traditionally, Unix systems store such information in flat text files, such as those in the /etc directory. In fact, the Unix /etc directory could be seen as a primitive directory service. Other examples of directory services include Sun's Network Information Service (NIS)[84] and Microsoft's Active Directory.[85] The legacy directory service in Mac OS X Server is called NetInfo. Although no longer used for shared directories, NetInfo is still the directory service for the local directory domain on Mac OS Xthat is, for users and resources on the local system. [83] LDAP stands for Lightweight Directory Access Protocol. It is a widely deployed open standard. [84] An old name for NIS is Yellow Pages (yp). The successor to NIS is called NIS+. Recent versions of Solaris have deprecated NIS and NIS+ in favor of LDAP-based directory services. [85] Active Directory is LDAP-based as well. The dscl command can be used for operating on data sources, which can be directory node names or hosts that are running directory services. Similarly, the niutil command utility can be used for operating on NetInfo domains. However, note that Open Directory includes a NetInfo plug-in that allows interoperation with NetInfo. Figure 237 shows examples of using dscl and niutil. Figure 237. Interacting with Directory Services by using command-line tools
2.14.3.3. Managing System Configuration
The scutil command can be used to access and manipulate various configuration aspects of the local system. The System Configuration daemon (/usr/sbin/configd) stores relevant configuration data in a dynamic store that is accessible via scutil. It uses several configuration agentseach of which is a plug-in that handles a particular configuration management areato form an overall view of system configuration. The agents reside in /System/Library/SystemConfiguration/ as bundles. For example, the IPConfiguration agent is responsible for establishing (say, via DHCP) and maintaining IPv4 addresses. Figure 238 shows an example of accessing the system configuration dynamic store using scutil. Figure 238. Using the scutil command to access the System Configuration dynamic store
2.14.4. The Auditing System
The Mac OS X auditing system consists of kernel support and a suite of user-space programs.[86] The kernel records audit events to a log filean audit trail filebased on several types of criteria. A user-space daemonauditdlistens to trigger events from the kernel and control events from user programs (the audit command-line utility by default). Trigger events inform auditd if the current log file has become full or if the file system free space has fallen below a configured threshold; if so, auditd will attempt to rectify the situation. For example, it may attempt to rotate the log. In this sense, auditd is a log management daemon. Control events are used to instruct auditd to switch to a new log file, reread the configuration file, or terminate the auditing system. [86] In Mac OS X 10.4, user-space auditing programs and configuration files are provided by the Common Criteria Tools package, which is not installed by default. Table 22 lists the key executables and configuration files in the auditing system.
Auditing can be enabled or disabled by setting the AUDIT variable to -YES- or -NO-, respectively, in the /etc/hostconfig file. The variable can also be set to -FAILSTOP- or -FAILHALT-, both of which enable auditing with additional conditions. The former runs auditd with the -s argument, which specifies that individual processes will stop if the audit log becomes full and running the processes will result in loss of audit records. The latter runs auditd with the -h argument, which specifies that the system should halt in case of an auditing failure. The kernel logs to only one audit trail file at a time. Trail filenames use a specific format: a string consisting of the file's creation time, followed by a period, followed by the termination time. The name of the active trail filethat is, the one that has not been terminated yetcontains the string not_terminated instead of the termination time. Both time substrings are constructed by using the %Y%m%d%H%M%S format specifier with the strftime() function. The audit_control, audit_user, and audit_warn files are typically modified to configure the auditing system. Figure 239 shows the representative contents of an audit_control file. Figure 239. An audit control file
|
Категории