| name | mainframe-security |
| description | IBM z/OS, RACF (Resource Access Control Facility), CICS, DB2, JES2, TSO/ISPF penetration testing; APF library abuse, dataset access control, SNA/Appc attacks, and legacy mainframe security assessment for financial/government environments. |
| origin | github-trending-2026 |
| version | 1.0.0 |
| compatibility | ["claude-code","agent-sdk","openclaw","cursor"] |
| allowed-tools | ["Bash","Read","Edit","Write","Glob","Grep"] |
| metadata | {"domain":"mainframe","category":"mainframe","tool_count":13,"guide_count":4,"mitre":"TA0006-Credential Access, T1078-Valid Accounts, T1003-OS Credential Dumping","keywords":["mainframe","zos","racf","cics","db2","jes2","tso","ispf","apf","sna","jcl","ibm-z","vtam","tk4"]} |
Skill: Mainframe Security (IBM z/OS / RACF)
Supplementary Files:
payloads.md -- 18 sections covering mainframe ecosystem, Hercules lab setup, TN3270, TSO/ISPF, RACF commands, APF library audit, dataset access, JCL, CICS, DB2, SNA, JES2, IRRDBU00 unload, SEAR API, z/OSMF REST, SMF detection, and a quick reference cheat sheet
test-cases.md -- 12 structured test cases (TC-MF-001..012) covering lab bring-up, TN3270, TSO/ISPF, RACF enumeration, APF audit, dataset access, JCL submission, CICS, DB2, JES2, IRRDBU00, and SEAR API
guides/mainframe-security-playbook.md -- Deep-dive operational playbook covering z/OS architecture, lab construction, RACF methodology, real-world incidents, and defense patterns
Summary
Mainframe security covers authorized penetration testing of IBM z/OS, z/VM, and z/VSE systems that still run the core transaction workloads for the global banking, insurance, airline, retail, and government sectors. Despite the "legacy" label, mainframes process the majority of the world's credit card transactions, social security records, and stock trades. A single compromised RACF user ID or APF-authorized library can expose millions of account records, defeat separation of duties, and enable persistent privileged access that survives normal patch cycles. This skill domain covers the specialized toolchain and methodology required to assess these environments: TN3270 terminal emulation, TSO/ISPF navigation, RACF user and group enumeration, APF (Authorized Program Facility) library audit, dataset access control testing, CICS transaction testing, JES2 job submission abuse, and the use of the IRRDBU00 database unload utility and the SEAR (Security API) REST interface for programmatic assessment.
Domain: mainframe
MITRE ATT&CK: TA0006-Credential Access, T1078-Valid Accounts, T1003-OS Credential Dumping
Description
Mainframes occupy a peculiar position in the security landscape. They are simultaneously the most hardened general-purpose platforms ever shipped (hardware-assisted isolation via PR/SM, EBCDIC vs ASCII impedance mismatch, RACF mandatory access control, crypto express cards) and one of the most operationally fragile: the average z/OS system operator is older than the average red teamer, the skills gap is widening, and most internal pentest teams lack anyone who can credibly navigate ISPF. This makes mainframe assessments high-leverage. When a tester can reach a TN3270 session, read a LISTUSER dump, and audit APF libraries, they are often operating in a part of the estate that has not been independently tested in years.
The attack surface on z/OS differs fundamentally from Linux/Windows environments. There are no traditional "open ports" in the same sense; instead, there are subsystems (CICS, DB2, IMS, JES, VTAM, TSO, z/OSMF, FTP, HTTP) each fronted by RACF for authentication and resource authorization. A typical engagement proceeds by: (1) reaching the TN3270 listener or the z/OSMF REST API, (2) obtaining or guessing a low-privilege TSO user ID, (3) enumerating RACF users, groups, and dataset access rules, (4) auditing APF libraries for writable datasets that would grant authorized-program status, (5) escalating to SPECIAL or AUDITOR attribute holders, and (6) demonstrating impact by reading sensitive datasets or submitting privileged JCL.
This skill emphasizes realistic, authorized assessment techniques against lab targets built from freely available components: the Hercules open-source mainframe emulator running MVS 3.8j Tur(n)key 4- (TK4-) or MVSCE, the open-source SEAR project for RACF REST testing, and mainframed/Enumeration for scripted discovery. Commands and JCL examples reflect real z/OS syntax so that practitioners can move from the lab to a client engagement without relearning the grammar.
Use Cases
- RACF User and Group Assessment -- Enumerate user IDs via
LISTUSER / SEARCH, dump group connectivity via LISTGRP, identify SPECIAL/AUDITOR/OPERATIONS attribute holders, and audit password rules and revoked-but-not-deleted accounts.
- APF Library Audit -- Identify APF-authorized libraries (system and dynamic), check whether any are backed by user-writable datasets, and demonstrate the impact of planting a payload in an authorized library.
- Dataset Access Control Testing -- Enumerate cataloged datasets via
LISTCAT/LISTDSN, test READ/UPDATE/ALTER/CONTROL access rules via PERMIT review, and identify over-permissive UACC (universal access) settings.
- CICS Transaction Testing -- Discover transaction codes via
CEDA VIEW, test for unsigned or overridden transactions, and assess CICS Web Services and CICS TSQ/TDQ abuse.
- JES2/JES3 Job Submission -- Review JOB card credentials, submit JCL via internal reader or
SUBMIT, and test for job classes that allow execution outside intended windows.
- TN3270 Mainframe Pentest -- Reach the TN3270 listener, negotiate terminal type, log on to TSO, navigate ISPF, and pivot to CICS/DB2/IMS as the user's access permits.
- JCL and Batch Code Review -- Audit production JCL for hardcoded credentials, missing RACF
USER=/PASSWORD= obfuscation, dataset disposition abuse, and unauthorized step library overrides.
Core Tools
| Tool | Category | Purpose |
|---|
| mainframed/Enumeration | Enumeration | Open-source collection of REXX scripts and TSO commands for z/OS reconnaissance: user/group enumeration, APF list, dataset discovery, RACF info |
| SEAR (Mainframe-Renewal-Project) | API Testing | Security Environment for Auditing RACF -- REST API wrapper around native RACF services for programmatic user/group/dataset testing |
| IBM Security zSecure Audit | Audit | Commercial RACF audit and reporting suite; reference standard for client-side reporting and CARLa command generation |
| Zowe | Integration | Open-source framework for z/OS modernization; exposes z/OSMF REST APIs and CLI tooling for jobs, files, and datasets |
| Hercules | Emulator | Open-source System/370, ESA/390, and z/Architecture emulator; foundation for free MVS 3.8j (TK4-/MVSCE) mainframe labs |
| Tur(n)key 4- (TK4-) | Lab Distribution | Pre-built MVS 3.8j distribution for Hercules; free, runnable on commodity hardware; de facto standard mainframe learning lab |
| MVSCE | Lab Distribution | Community Edition MVS 3.8j distribution, alternative to TK4-; integrates tooling and sample datasets for security practice |
| x3270 / c3270 / wc3270 | Terminal | TN3270E terminal emulators (X/Windows, curses, Windows console); the canonical way to reach a mainframe session |
| tn3270 client (various) | Terminal | Any conformant TN3270 terminal emulator; alternatives include Vista, IBM Personal Communications, IBM Host On-Demand |
| RACF TSO commands | Auth & Access | LISTUSER, LISTGRP, SEARCH, ADDUSER, ALTUSER, DELUSER, CONNECT, PERMIT, PASSWORD, SETROPTS |
| ISPF / SDSF | Operator UI | Interactive System Productivity Facility (developer/operator UI); System Display and Search Facility (job, output, and log browsing) |
| CICS Explorer / CEDA | CICS Admin | CICS Transaction Server administration; CEDA (CICS Execution Definition Online) for resource definition and transaction discovery |
| IBM Health Checker for z/OS | Hardening | Native health-check framework; runs checks against z/OS Security Server, RACF, and z/OSMF; useful baseline for client-side hardening gaps |
Methodology
Phase 1: TN3270 Recon and Session Acquisition
Reach the mainframe's interactive surface and obtain an initial TSO session.
- Identify TN3270 listeners (
nmap -p 23,992,1027 --script=tn3270-info); record the VTAM applid and any banner text.
- Connect with
x3270 host:port, negotiate TN3270E, and capture logon screens (TSO, CICS, IMS, NATURAL).
- Probe default logon IDs against the TSO logon panel (IBMUSER, SYSADM, ADCDA, et al.) using account-specific practices.
- Enumerate z/OSMF REST endpoints (
https://host/zosmf/) for jobs, files, and REST API info if the REST interface is reachable.
- Record the security server banner (RACF vs ACF2 vs Top Secret); methodology below assumes RACF.
Phase 2: User, Group, and Attribute Discovery
Map the identity and privilege landscape.
- Run
LISTUSER * (or SEARCH FILTER(*) for a thinner sweep) to enumerate user IDs, default groups, attributes, and last-change dates.
- Run
LISTGRP * to enumerate groups, owners, and connected users; identify the SYSADM and operations groups.
- Filter for SPECIAL, AUDITOR, and OPERATIONS attribute holders; these are the RACF equivalent of Domain Admins.
- Identify REVOKED users that have not been DELETED (often retain dataset ownership and group memberships).
- Collect PASSDATE/PASSWORD-INTERVAL data to flag dormant accounts.
Phase 3: RACF Testing -- Rules, Datasets, and Resources
Test the authorization layer against the enumerated user base.
- Run
SEARCH CLASS(DATASET) FILTER(**) to enumerate cataloged dataset profiles.
- For each sensitive dataset pattern (
SYS1.**, PROD.**, PAYROLL.**), review LISTDSD and PERMIT output for UACC and access list.
- Identify datasets where UACC=READ/UPDATE/ALTER that should be NONE, and access list entries that grant broad group access.
- Check the general resource classes (
FACILITY, TERMINAL, SURROGAT, STARTED, OPERCMDS) for over-permissive profiles.
- Document violations and propose
PERMIT / ALTDSD fixes with least-privilege defaults.
Phase 4: Dataset Access and APF Library Audit
Hunt for the highest-leverage escalation primitives on z/OS: writable datasets that back APF libraries.
- Run
SETR LIST to dump current APF list (system APF and dynamic APF).
- For each APF library dataset, run
LISTDSD DATASET(...) and verify UACC and access list; identify user-writable entries.
- Cross-reference writeable APF datasets against the current user's group memberships; flag any effective write path.
- Examine LINKLIST and LPA libraries for unauthorized additions; check
PROGxx member additions.
- Demonstrate (in lab) the planting of an authorized program in a writeable APF dataset; for client work, document the finding without execution.
Phase 5: Privilege Escalation and Impact Demonstration
Convert the access-control findings into demonstrable impact.
- Identify paths to SPECIAL/AUDITOR/OPERATIONS via group ownership chain abuse or SURROGAT class exploitation.
- Read sensitive production datasets (read-only demonstration) to prove data exposure scope.
- Submit benign JCL via internal reader or
SUBMIT to demonstrate batch execution capability and JES2 class abuse.
- Pivot to CICS or DB2 subsystems via stored user credentials and linked transaction configurations.
- Compile findings, propose hardening (
ALTDSD, PERMIT, SETROPTS, APF list cleanup, password policy), and document detection gaps in SMF/RACF audit.
Practical Steps
Step 1: Build a Mainframe Lab with Hercules and TK4-
The free, reproducible foundation for all mainframe skill practice.
sudo apt-get install build-essential cmake libssl-dev flex bison git \
autoconf automake libtool pkg-config
git clone --depth=1 https://github.com/SDL-Hercules-390/hyperion.git
cd hyperion
./util/bldcnf.pl
./configure --prefix=/opt/hercules
make -j"$(nproc)"
sudo make install
mkdir -p ~/mf-lab && cd ~/mf-lab
wget https://github.com/MVS-SOW/tk4-/archive/refs/heads/master.tar.gz
tar xzf master.tar.gz && cd tk4--master
./mvs -t 3270-2
c3270 localhost:3270
Step 2: Enumerate RACF Users via TSO Commands
Once logged into TSO, drop to READY and run RACF commands via IKJEFT01.
LISTUSER *
SEARCH FILTER(USER*) CLIST(NAME)
LISTUSER IBMUSER
LISTGRP *
SEARCH FILTER(*) CLIST(NAME)
Step 3: Audit APF Libraries
SETR LIST
LISTDSD DATASET('MYUSER.LINKLIB') ALL
Step 4: Use SEAR for Programmatic RACF Testing
curl -k -u "$SEAR_USER:$SEAR_PASS" \
"https://mf-target/zosmf/api/rest/sear/users" \
| jq '.users[] | {name: .name, attributes: .attributes}'
curl -k -u "$SEAR_USER:$SEAR_PASS" \
"https://mf-target/zosmf/api/rest/sear/datasets/SYS1.LINKLIB" \
| jq '.access'
curl -k -u "$SEAR_USER:$SEAR_PASS" \
"https://mf-target/zosmf/api/rest/sear/groups/ADMGP" \
| jq '.users[]'
Defense Perspective
Hardening RACF
- Enforce eight-character-or-greater passwords with mixed-case alpha-numeric-symbol composition; enable mixed-case via
SETROPTS PASSWORD(ALWNUMIC,ALWSYMBL,MIXEDCASE).
- Run
SETROPTS LIST regularly and audit for insecure options (SAUDIT, CMDVIOL, OPERAUDIT enabled; CATDSNS sensible).
- Strip SPECIAL/AUDITOR attributes from non-essential user IDs; implement just-in-time elevation via secondary IDs.
- Delete REVOKED users promptly; they retain dataset ownership and group memberships until
DELUSER.
APF and Linklist Hygiene
- Restrict dynamic APF additions to controlled change windows; review
PROGxx members at every change.
- Mark APF datasets as READ-only at the storage layer (RACF
UACC=READ, DFSMS ERASE/READPASS).
- Periodically run IBM Health Checker
APF_CHECK and reconcile against the gold source.
Audit and Detection
- Enable SMF type 30 (job/step), 80 (RACF), 81 (RACF), and 83 (tape) records; ship to SIEM with timestamp, userid, and resource class.
- Implement
CMDVIOL and OPERAUDIT so that command violations and operator actions are auditable.
- Forward RACF SMF to a separate LPAR or off-platform collector that the SPECIAL user on the assessed LPAR cannot alter.
Encryption and Isolation
- Enable Coupling Facility (CF) encryption for shared DASD and CF structures.
- Use z/OS Encryption Readiness Technology (zERT) for in-flight TLS on FTP, TN3270, and z/OSMF.
- Isolate development and production LPARs via PR/SM and z/VM partitioning; never share DASD pools across trust boundaries.
Multi-Level Security
- Where classification is required, use RACF MLS (Multi-Level Security) mode for labels and mandatory access control rather than discretionary UACC.
- Document SECLABEL ownership and review periodically; mis-assignment of a high-water-mark label defeats MLS.
Differentiation
This is the only mainframe-focused skill domain in the workspace. Adjacent skills provide complementary coverage without overlap:
ad-ldap-attack covers enterprise identity on Active Directory / LDAP, which is a separate identity stack from RACF/ACF2/Top Secret. Cross-domain (AD-to-mainframe) trust analysis is the boundary between the two skills.
database-attack covers RDBMS exploitation generally (MSSQL, Oracle, PostgreSQL); DB2 for z/OS specifics (plan/package security, DB2I, SPUFI) live here.
network-pentest and network-sniffing-mitm cover the IP network that fronts TN3270 and z/OSMF; this skill picks up at the TN3270 session itself.
osint may surface mainframe indicators (JOB card credentials in source repositories, IBM doc leaks) that feed into this skill's enumeration phase.
No other skill covers RACF, APF, CICS, JES2, or z/OS dataset access control. The mainframe ecosystem is sufficiently distinct (EBCDIC, JCL, REXX, ISPF) that the techniques do not transfer cleanly from Unix/Windows pentest skills.