Program Security
Chapter 31
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-1
Program Security Chapter 31 Computer Security: Art and Science , 2 - - PowerPoint PPT Presentation
Program Security Chapter 31 Computer Security: Art and Science , 2 nd Edition Version 1.0 Slide 31-1 Chapter 29: Program Security Introduction Requirements and Policy Design Refinement and Implementation Common
Chapter 31
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-1
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-2
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-3
role account
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-4
1. Access to role account based on user, location, time of request 2. Settings of role account’s environment replaces corresponding settings of user’s environment, but rest of user’s environment preserved 3. Only root can alter access control information for access to role account
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-5
4. Mechanism provides restricted, unrestricted access to role account
5. Access to files, directories, objects owned by role account restricted to those authorized to use role account, users trusted to install system programs, root
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-6
thereby revealing authentication information to UU
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-7
threat requirement notes 1 1, 5
Restricts who can access role account, protects access control data
2 1
Restricts location from where user can access role account
3 3
Restricts change to trusted users
4 2, 4, 5
User’s search path restricted to own
role account can manipulate executables
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-8
perform
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-9
threat requirement notes 5 4
Allows user restricted access to role account, so user can run only specific commands
6 2, 5
Prevent introduction of Trojan horse
7 3
root users trusted; users with access to role account trusted
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-10
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-11
(restricted access)
role role_account [ command ]
where
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-12
1.Obtain role account, command, user, location, time of day
2.Check user allowed to access role account
a) at specified location; b) at specified time; and c) for specified command (or without restriction)
If user not, log attempt and quit
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-13
3. Obtain user, group information for role account; change privileges
4. If user requested specific command, overlay process with command interpreter that spawns named command 5. If user requested unrestricted access, overlay process with command interpreter allowing interactive use
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-14
by time, location
access to role account
Level of access (restricted, unrestricted) depends on user, role, time, location
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-15
data structures
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-16
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-17
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-18
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-19
role account user names locations from which the role account can be accessed times when the role account can be accessed command and arguments
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-20
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-21
*local* , control.fixit.com , .watchu.edu
peter , paul , mary , joan , janis
Monday-Thursday 9a.m.-5p.m.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-22
Mon-Thu 9AM-5PM
Mon 9AM-Thu 5PM
Apr 15 8AM-Sep 15 6PM
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-23
/bin/install *
/bin/cp log /var/inst/log
/usr/bin/id
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-24
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-25
boolean accessok(role rname, command cmd); stat ¬ false user ¬ obtain user ID timeday ¬ obtain time of day entry ¬ obtain entry point (terminal line, remote host)
repeat rec ¬ get next record from file; EOF if none if rec ≠ EOF then stat ¬ match(rec, rname, cmd, user, timeday, entry) until rec = EOF or stat = true close access control file return stat
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-26
then true
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-27
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-28
accounts, so no need to revisit any
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-29
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-30
int accessok(uid_t rname, char *cmd[]);
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-31
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-32
userid = getuid();
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-33
timeday = time(NULL);
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-34
entry = getlocation();
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-35
if ((fp = fopen(acfile, “r”)) == NULL){ logerror(errno, acfile); return(stat); }
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-36
do { acrec = getnextacrec(fp); if (acrec != NULL) stat = match(rec, rname, cmd, user, timeday, entry); } until (acrec == NULL || stat == 1);
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-37
(void) fclose(fp); return(stat);
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-38
remote host (if any) in file utmp
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-39
trusted
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-40
hostname getlocation() myterm ¬ name of terminal associated with process
if any user other than root can alter it then return “*nowhere*”
repeat term ¬ get next record from utmp file; EOF if none if term ≠ EOF and myterm = term then stat ¬ true else stat ¬ false until term = EOF or stat = true if host field in utmp record = empty then host ¬ “localhost” else host ¬ host field of utmp record close utmp file return host Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-41
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-42
convert
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-43
is number of commands fields
record role rname string userlist string location string timeofday string commands[] … string commands[] integer numcommands end record;
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-44
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-45
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-46
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-47
process has the privileges it needs
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-48
privileges, which require program to call module
chances of other parts of program corrupting those modules
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-49
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-50
privileges
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-51
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-52
control files, must be protected from unauthorized use and modification. Any such modification must be detected.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-53
variables, included files, etc.), check them
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-54
possible, document them for the installers and maintainers, so they know the assumptions that attackers will try to invalidate.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-55
group; these users need not be listed in group file to be group members
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-56
program, and that other programs cannot access the memory of a privileged process.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-57
memory is not to contain executable instructions, turn execute permission
not to be altered, make that section read-only.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-58
errors whenever possible, and identify those components for which error checking will not work.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-59
implementation
unless the cause of the error, and its effects, do not affect any security
state before the process began, and then terminate.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-60
failed, anyone could have mail appended to any file to which default user could write
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-61
desired
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-62
that of role
this is how privileges restored
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-63
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-64
known and, for all such interactions, the process must enforce the required security policy.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-65
those that are local to the exception handling module. An exception handler should block all other exceptions when begun, and should not release the block until the handler completes execution, unless the handler has been designed to handle exceptions within itself (or calls an uninvoked exception handler).
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-66
stack
return address used
arrays
authenticates you!
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-67
from untrusted sources (such as input) should be kept in separate areas of
untrusted source, a memory error will occur.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-68
terminate program
check all array, pointer references; any out-of-bounds reference invokes exception handler
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-69
libraries when program needs them
created and the time it is run.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-70
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-71
name.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-72
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-73
identifies the correct object.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-74
interpretation
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-75
reallocated
confidential information or one that should not be altered), the object should be erased, then deallocated or deleted. Any resources not needed should also be released.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-76
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-77
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-78
function that manipulates arrays cannot ensure that only valid elements are referenced, do not use that function. Find one that does, write a new version, or create a wrapper.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-79
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-80
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-81
can check
inconsistencies in types. Investigate all such warnings and either fix the problem or document the warning and why it is spurious.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-82
erroneously
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-83
unless return value doesn’t matter
is closed
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-84
for as long as the program is used!
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-85
to shell for execution
program
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-86
(keyword “not”)
trainees
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-87
procedure that can weaken security, document the reasons for the decision, the possible effects, and the situations in which the compromise method should be used. This informs others of the trade-off and the attendant risks.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-88
for values that are too big or too small, and check character data for length and valid characters.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-89
printf(“%d %d%n %d\n%n”, i, j, &m, i, &n);
stores 4 in m and 7 in n
printf(str)
User enters “log%n”, overwriting some memory location with 3
memory location to any desired value
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-90
factors
means “NULL”)
validated
validated.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-91
role name users comma-separated list of users location comma-separated list of locations time comma-separated list of times command command and arguments … command command and arguments endrole
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-92
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-93
files after validation but before opening
access check on file descriptor
unless closed, this provides protection
system call!
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-94
that all possible sequences of the program(s) involved match one (or more) legal sequences.
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-95
but root can
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-96
root access to fix problem
su couldn’t open any files—not even password file
descriptors
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-97
documentation, design reviews, and code reviews) to ensure that
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-98
denies access
unsigned; check there are no comparisons with negative numbersr
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-99
matches pattern in location field of access control entries, and module acts appropriately
disabling the entry; violates Requirement 4
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-100
account, either it continued in face of error, or it overrode user’s attempt to terminate program
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-101
execution environment
system with different environment
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-102
minor problems
major problems
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-103
testing environment!
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-104
place of uncompleted modules
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-105
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-106
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-107
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-108
that file
inputs
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-109
mail –s hostname netadmin
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-110
it
independent assessment of documentation, correctness of instructions
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-111
people can alter it and from where it can be sent to recipients
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-112
redistributed
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-113
compromised when they downloaded and installed it
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-114
techniques
Version 1.0 Computer Security: Art and Science, 2nd Edition Slide 31-115