Environment Variables and Attacks Flashcards

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/17

flashcard set

Earn XP

Description and Tags

Flashcards covering topics of Environment Variables and Attacks discussed in the lecture notes.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

18 Terms

1
New cards

Environment Variables

A set of named-value pairs stored inside each process’s memory, part of the operating environment in which a process runs, and can be set by users before a program runs.

2
New cards

Opportunity Created by Environment Variables

A variable that can be used to affect programs' behaviors, especially dangerous for privileged programs, such as the PATH variable.

3
New cards

Accessing Environment Variables in Programs

Functions like getenv(var_name), putenv(), setenv(), and unset() are used.

4
New cards

How Processes Obtain Environment Variables

A child process inherits its parent's variables via fork(), and a process running a new program loses old variables unless execve() is specially invoked to pass them.

5
New cards

Memory Location for Environment Variables

They are stored on the stack of a process's memory before main() is invoked.

6
New cards

Shell Variables

Internal variables used by a shell program; different from environment variables, which are copied into shell variables upon a shell program's start.

7
New cards

/proc File System

A virtual file system in Linux containing directories for each process (named by process ID), with each directory having an 'environ' file containing the process's environment variables.

8
New cards

Attack Surface of Environment Variables

Users can set environment variables, making them a part of the attack surface, especially on Set-UID programs.

9
New cards

Linker and Environment Variables

Linkers use environment variables to find libraries, creating opportunities for attackers to inject malicious libraries, especially during dynamic linking.

10
New cards

Dynamic Linking

Uses environment variables, representing a part of the attack surface that can be exploited.

11
New cards

Dynamic Linker Risks (LDPRELOAD, LDLIBRARY_PATH)

LDPRELOAD contains a list of shared libraries searched first by the linker, while LDLIBRARY_PATH specifies other folders; both can be manipulated by users to control linking outcomes.

12
New cards

Attack Surface Expansion via External Programs

A program may invoke external programs, inheriting the calling process’s privileges; if the external program uses environment variables, it expands the attack surface.

13
New cards

Attack Surface: PATH Variable

Shell programs rely on the PATH variable to locate commands, making it susceptible to manipulation by attackers.

14
New cards

Attack Surface: Library Functions

Environment variables used by library functions can become part of the attack surface if these functions are invoked by privileged programs.

15
New cards

Locale in UNIX

LANG, LANGUAGE, NLSPATH, LOCPATH, LCALL, LCMESSAGES are used by this subsystem that can be controlled by users to manipulate translated messages.

16
New cards

Attack Surface: Application Code

Developers make incorrect assumptions about environment variables, leading to inadequate sanitization and potential security flaws.

17
New cards

Set-UID vs. Service Approach

Normal users run a special program to gain root privileges temporarily, whereas in the service approach, normal users request a privileged service to perform actions for them.

18
New cards

Attack Surface Comparison Between Set-UID and Service Approaches

The first has a broad attack surface due to untrusted environment variables, while the second is safer but still subject to other attack surfaces.