Mainframe applications still move a large share of the world's payments and policy records, yet their application-layer security is often assumed to be handled by RACF and never reviewed. RACF, ACF2 or Top Secret decide who may log on and which datasets they may open, but the COBOL program, the CICS transaction definitions, the Db2 packages and the APIs that now expose them to the web decide what an authenticated user can actually do. This guide covers CICS transaction, resource and command security, Db2 static and dynamic SQL, COBOL coding risks and compiler checks, MQ and z/OS Connect exposure, and how to test and monitor mainframe applications. It is for application security teams, mainframe developers and system programmers, and auditors who need to review a CICS or batch application rather than the operating system beneath it.
Key takeaways
- CICS security is a set of switches, not one setting. Nothing is checked unless
SEC=YES, and each resource type (transactions, files, programs, commands) has its own system initialisation parameter that can be left off. - Transaction security is not resource security. Being allowed to start a transaction does not mean the user should reach every file, program or queue it touches;
RESSECand theXparameters make CICS check those too. - Dynamic SQL in COBOL can be injected. Statements built by string concatenation and run with
EXECUTE IMMEDIATEhave the same flaw as any web application; use static SQL orPREPAREwith parameter markers. - APIs change the threat model. z/OS Connect, CICS web services and MQ bridges put decades-old transactions behind internet-facing APIs, so input that was once constrained by a 3270 screen now arrives as JSON from anywhere.
- Identity must survive the hop. Map the distributed caller to a real RACF user ID or a tightly scoped functional ID, never a single all-powerful gateway account.
Where application security sits on z/OS
Platform security and application security overlap on the mainframe more than elsewhere, because the External Security Manager (RACF, CA ACF2 or CA Top Secret) enforces both. The distinction that matters for reviewers is who configures what.
| Layer | What enforces it | Who usually owns it | Typical application-level question |
|---|---|---|---|
| Sign-on and user IDs | ESM user profiles, MFA for TSO and CICS | Security administration | Does the application have a default user with too much access? |
| CICS transactions, programs, files, queues | CICS calling the ESM, controlled by SIT parameters | CICS system programmers and application teams | Which transactions can each role run, and what can those transactions reach? |
| Db2 data | Db2 privileges, package and plan ownership, DYNAMICRULES | DBAs | Does the package owner hold broad privileges that dynamic SQL inherits? |
| Program logic | COBOL, PL/I or Assembler code | Application developers | Does the program check that the account belongs to the caller? |
| Interfaces | z/OS Connect, CICS web services, MQ, FTP and batch file feeds | Integration and middleware teams | How is the remote caller authenticated and mapped to a z/OS identity? |
For the identity layer itself, see the Mainframe Identity and RACF Security Guide, and for started tasks, batch user IDs and surrogate job submission see the Mainframe Service Accounts and Batch Job Identity Guide. This page focuses on what the application does with that identity.
CICS security controls
IBM's CICS documentation is explicit that CICS performs its security checks only if the SEC system initialisation parameter is YES. Beyond that, each class of resource is switched on separately.
| SIT parameter | What CICS checks | Review point |
|---|---|---|
XTRAN | Whether the user may attach (start) the transaction | Transaction profiles map to job roles; no generic profile granting all transactions to all users |
XFCT | Access to CICS-managed VSAM and BDAM files | Update access only for transactions that need it |
XPPT | Which programs a user may LINK, XCTL or LOAD | Back-end programs callable only through their front-end transaction |
XDCT and XTST | Transient data and temporary storage queues | Queues holding customer data are protected, not just named obscurely |
XCMD | System programming commands (with CMDSEC) | SPI commands such as SET and INQUIRE restricted to operators and tooling |
XPCT | Started transactions and related commands | Who can START or CANCEL other users' work |
XDB2 | DB2ENTRY resources | Db2 thread definitions protected |
XRES | Newer resources such as BUNDLE, JVMSERVER, DOCTEMPLATE, ATOMSERVICE and XMLTRANSFORM | Often left off in regions upgraded from older releases |
XUSER | Surrogate user checks when a command associates a user ID with a resource | Prevents a task acting as another user without authority |
- Resource security per transaction: the resource checks run only when
RESSECapplies to the transaction as well as the relevantXparameter being on. Failures returnNOTAUTHwith RESP2 101 (resource), 100 (command) or 102 (surrogate), which makes them easy to find in application error handling and logs. - BMS is not a control: IBM states that no authorisation processing is done for BMS commands. Fields that are protected or hidden on a 3270 map can still be altered by an emulator or screen-scraping tool, so the program must re-validate everything it receives.
- Default user: work that runs without sign-on runs as the region's default user. Give it access to public transactions only.
- Security discovery: CICS TS 6.2 and later document security discovery statistics, produced with the
DFH$SDDPjob, that count resource checks made or that would have been made by SIT parameter. Use them to build profiles before switching a resource class on in production. - Region separation: keep test and production CICS regions under different region user IDs and different security prefixes, so a test transaction definition never grants production access.
Db2 access from COBOL: static, dynamic and package authority
Most COBOL batch and CICS programs use static embedded SQL, which is precompiled and bound into a package. Static SQL with host variables is not injectable in the usual sense: the statement text is fixed at bind time and values are passed as data. The risk appears with dynamic SQL.
- EXECUTE IMMEDIATE: IBM's Db2 for z/OS documentation notes that
EXECUTE IMMEDIATEprepares and runs a statement in one step and does not allow parameter markers. If the statement string is assembled from user input, the input becomes SQL. - PREPARE with parameter markers: a prepared statement uses
?parameter markers whose values come from host variables named onEXECUTE ... USING, so input is never parsed as SQL. Treat this as the only acceptable dynamic pattern for values. Identifiers such as table or column names cannot be parameterised and must come from an allow list. - DYNAMICRULES: this bind option decides whose privileges dynamic SQL uses. With bind behaviour, dynamic SQL runs with the privileges of the package or plan owner; with run behaviour, with the privileges of the executing user. A package owned by a powerful ID and bound with bind behaviour turns any injection into access to everything that owner can reach.
- Least privilege for package owners: bind packages under dedicated owner IDs that hold only the privileges the package needs, and restrict who can
BINDandREBIND. - Distributed access: JDBC and ODBC clients reaching Db2 through DDF run dynamic SQL; the same parameter marker rule applies, and the connecting ID is a non-human identity that needs rotation and monitoring.
The principles are the same as in any database; see the Secure Code Review Guide for how to fold them into review.
COBOL coding risks and compiler checks
COBOL is not prone to the classic C buffer overflow in the same way, but it has its own failure modes, and several matter for security as well as reliability.
| Risk | What goes wrong | Control |
|---|---|---|
| Out-of-range subscripts and reference modification | A table index from input reads or overwrites adjacent storage | Validate bounds where input enters; SSRANGE in test builds |
| Invalid numeric data | Non-numeric bytes in a numeric field cause abends or wrong arithmetic | IS NUMERIC tests on input; NUMCHECK in test builds |
| Called program writing past caller storage | Parameter length mismatch corrupts WORKING-STORAGE | PARMCHECK during testing and migration |
| Trusting COMMAREA, channel or map data | An account number or role flag is taken from the screen or caller unchecked | Re-derive authority from the signed-on user ID (for example with EXEC CICS ASSIGN USERID) and server-side data |
| Missing ownership checks | Any user who can run the inquiry transaction can read any customer | Check record ownership or branch scope in the program |
| Ignored SQLCODE and RESP values | Failed security checks or SQL errors are treated as success | Check SQLCODE/SQLSTATE and RESP/RESP2 after every call |
| Credentials in source, JCL or PROCs | Passwords for FTP, Db2 or partner systems in plain text | PassTickets, certificates or a vault; scan source libraries |
IBM's Enterprise COBOL 6.4 performance guide explains the cost of these options: SSRANGE adds code to detect out-of-range storage references (about 5% slower in IBM's benchmark with moderate table use), NUMCHECK generates IS NUMERIC tests whenever a numeric item is a sender, and PARMCHECK places a check buffer after WORKING-STORAGE to detect overwrites by called programs. The guide recommends the NO forms for production performance and manual IS NUMERIC tests where data enters the program. A sensible pattern is to enable the checks in test and regression builds, and to code explicit validation at every trust boundary in production code.
APIs, MQ and other entry points
- z/OS Connect: IBM documents authentication by basic credentials verified by SAF or LDAP, TLS client certificates, or a JWT from a trusted issuer; mapping of the distributed identity to a SAF user ID; and role-based authorisation where roles are defined in the OpenAPI definition and correspond to LDAP groups, SAF policies or a JWT claim. Requests are audited with Liberty Audit 1.0 in a z/OS Connect container. The authenticated identity can flow to the system of record where it supports it; otherwise a functional identity is used, which then needs its own least-privilege scope.
- Validate at the API, again in the program: JSON schemas in the OpenAPI definition constrain input, but the COBOL program behind them was often written assuming 3270 field lengths. Validate length, type and range on both sides.
- IBM MQ for z/OS: security uses RACF classes including
MQCONN(connection),MQQUEUEandMXQUEUE(queues),MQPROC,MQNLIST,MXTOPIC,MQCMDS(commands) andMQADMINorMXADMIN(security switches, alternate user and context profiles). A CICS-MQ bridge or trigger that starts transactions on message arrival is an unauthenticated entry point unless queue access and alternate user authority are controlled. - Gateway identities: API gateways, CICS Transaction Gateway clients, RPA bots and ETL tools typically connect with one technical user ID. Where possible propagate the end user; where not, give the gateway ID only the transactions it fronts. See the API Gateway Security Guide.
- File and batch feeds: inbound files processed by batch COBOL are input too. Validate record layouts and counts, and protect the landing datasets.
Rolling out application security on a mainframe estate
- Inventory: list CICS regions with their SIT security parameters, Db2 packages with owners and
DYNAMICRULES, z/OS Connect APIs and MQ queues that start work. Record which applications are reachable from distributed systems. - Discover before enforcing: in a test region, turn on the missing
Xparameters and use security discovery statistics or ESM warning mode (RACFWARNINGprofiles) to see what would fail. - Fix the highest exposure first: API-exposed transactions, dynamic SQL and default user access.
- Code review and scanning: search COBOL and JCL libraries for
EXECUTE IMMEDIATE, string-built SQL, hard-coded passwords and uncheckedRESP. Several SAST tools support COBOL; see the SAST Triage Guide. - Test: include mainframe APIs and 3270 transactions in penetration tests, with authorisation testing for horizontal access (one customer reading another's data).
- Enforce in production in rings: one region or one application at a time, with a change window and a tested back-out (resetting the SIT parameter or profile at the next region restart, or removing a
WARNINGprofile). - Bring mainframe code into the SDLC: source in Git, pipeline builds, peer review and the same security gates as distributed code. See the Secure Software Development Lifecycle (SSDLC) Guide.
Small versus large estates: a single-region shop can often switch all CICS resource classes on in one programme. A bank with hundreds of regions and shared transactions should prioritise by exposure, and invest in automated profile generation from discovery data, because hand-written profiles will not keep up.
Detection and measurement
- SMF records: RACF violations and CICS security failures (
NOTAUTH) feed SMF type 80 records; route them to the SIEM with CICS region and transaction context. - z/OS Connect audit: Liberty audit events show who called which API and the mapped user ID.
- Db2 audit: audit policies on sensitive tables, and alerts on dynamic SQL from unexpected packages or IDs.
- Behaviour: one user ID reading many customer records in a short period, or a gateway ID running transactions outside its usual set.
Metrics:
- Percentage of production CICS regions with
SEC=YESand all relevantXparameters on. - Number of packages using dynamic SQL without parameter markers, trending to zero.
- Number of API-exposed transactions reached through a shared gateway ID rather than a propagated identity.
- Hard-coded credentials found in source and JCL libraries, and time to remove them.
- Share of mainframe applications in the same SAST and review pipeline as distributed code.
Framework mapping
| Framework | Reference | Mainframe application relevance |
|---|---|---|
| NIST SP 800-53 Rev. 5 | AC-3, AC-6 | CICS resource security, package owner privileges |
| NIST SP 800-53 Rev. 5 | SI-10, SA-11 | Input validation in COBOL; developer testing including compiler checks |
| NIST SP 800-53 Rev. 5 | CM-5, AU-12 | Who can BIND or change CICS definitions; SMF audit generation |
| NIST CSF 2.0 | PR.AA-05, PR.PS-06 | Least-privilege access; secure software development practices |
| OWASP ASVS 5.0 | V2.2.1, V8.2.1 | Positive input validation; function-level access for API-exposed transactions |
| ISO/IEC 27001:2022 | Annex A 8.28 Secure coding | COBOL coding standards and review |
| MITRE ATT&CK | T1190, T1078.003 | Exploiting exposed mainframe APIs; misuse of valid local accounts such as gateway IDs |
Common failure patterns
- XTRAN on, everything else off: users can only start approved transactions, but any program those transactions can LINK to, and any file, is open to them.
- The all-powerful gateway ID: a web or API front end connects as one user ID authorised for every transaction, so the distributed application's authorisation is the only control and is invisible to RACF.
- Hidden map fields as security: the program trusts a branch code or customer number written to a protected field, which a modified emulator can change.
- String-built dynamic SQL under a powerful package owner, combining injection with broad privileges via bind behaviour.
- Region upgrades that leave
XRESand newer resources unprotected, including JVM servers and bundles that can deploy code. - Passwords in JCL, PROCs and COBOL copybooks for FTP, Db2 or partner connections, readable by anyone with read access to the library.
Practitioner checklist
- Confirm
SEC=YESand review everyXSIT parameter in each production CICS region. - Restrict the CICS default user to public transactions only.
- Re-validate all COMMAREA, channel and map input in the program, and derive authority from the signed-on user.
- Replace
EXECUTE IMMEDIATEwith static SQL orPREPAREwith parameter markers; allow-list identifiers. - Bind packages under least-privilege owner IDs and review
DYNAMICRULES. - Use
SSRANGE,NUMCHECKandPARMCHECKin test builds and explicit validation in production code. - Map API callers to real or tightly scoped user IDs in z/OS Connect and protect MQ queues that start transactions.
- Scan source and JCL libraries for hard-coded credentials and move them to PassTickets, certificates or a vault.
- Send SMF security records and z/OS Connect audit events to the SIEM.
- Include mainframe transactions and APIs in SAST, code review and penetration testing.
Standards and references
- IBM: CICS TS, Security checking
- IBM: CICS TS, CICS and RACF resource checking summary
- IBM: CICS TS 6, Security discovery statistics
- IBM: Db2 12 for z/OS, Dynamic SQL statement preparation and execution
- IBM: Overview of z/OS Connect security
- IBM: MQ for z/OS RACF classes
- IBM: Enterprise COBOL for z/OS 6.4 Performance Tuning Guide
- NIST: SP 800-53 Rev. 5
Related NHI Mgmt Group resources: Mainframe Identity and RACF Security Guide · Mainframe Service Accounts and Batch Job Identity Guide · Identity Integration in M&A Guide · IBM i Security Guide