Join our Newsletter — 33% off our NHI Course
Home› Guides› Mainframe and COBOL Application Security Guide: Securing CICS,…
Guide Application Security

Mainframe and COBOL Application Security Guide: Securing CICS, Db2 and COBOL Code

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 14 min read
On this page

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; RESSEC and the X parameters make CICS check those too.
  • Dynamic SQL in COBOL can be injected. Statements built by string concatenation and run with EXECUTE IMMEDIATE have the same flaw as any web application; use static SQL or PREPARE with 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.

LayerWhat enforces itWho usually owns itTypical application-level question
Sign-on and user IDsESM user profiles, MFA for TSO and CICSSecurity administrationDoes the application have a default user with too much access?
CICS transactions, programs, files, queuesCICS calling the ESM, controlled by SIT parametersCICS system programmers and application teamsWhich transactions can each role run, and what can those transactions reach?
Db2 dataDb2 privileges, package and plan ownership, DYNAMICRULESDBAsDoes the package owner hold broad privileges that dynamic SQL inherits?
Program logicCOBOL, PL/I or Assembler codeApplication developersDoes the program check that the account belongs to the caller?
Interfacesz/OS Connect, CICS web services, MQ, FTP and batch file feedsIntegration and middleware teamsHow 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 parameterWhat CICS checksReview point
XTRANWhether the user may attach (start) the transactionTransaction profiles map to job roles; no generic profile granting all transactions to all users
XFCTAccess to CICS-managed VSAM and BDAM filesUpdate access only for transactions that need it
XPPTWhich programs a user may LINK, XCTL or LOADBack-end programs callable only through their front-end transaction
XDCT and XTSTTransient data and temporary storage queuesQueues holding customer data are protected, not just named obscurely
XCMDSystem programming commands (with CMDSEC)SPI commands such as SET and INQUIRE restricted to operators and tooling
XPCTStarted transactions and related commandsWho can START or CANCEL other users' work
XDB2DB2ENTRY resourcesDb2 thread definitions protected
XRESNewer resources such as BUNDLE, JVMSERVER, DOCTEMPLATE, ATOMSERVICE and XMLTRANSFORMOften left off in regions upgraded from older releases
XUSERSurrogate user checks when a command associates a user ID with a resourcePrevents a task acting as another user without authority
  • Resource security per transaction: the resource checks run only when RESSEC applies to the transaction as well as the relevant X parameter being on. Failures return NOTAUTH with 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$SDDP job, 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 IMMEDIATE prepares 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 on EXECUTE ... 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 BIND and REBIND.
  • 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.

RiskWhat goes wrongControl
Out-of-range subscripts and reference modificationA table index from input reads or overwrites adjacent storageValidate bounds where input enters; SSRANGE in test builds
Invalid numeric dataNon-numeric bytes in a numeric field cause abends or wrong arithmeticIS NUMERIC tests on input; NUMCHECK in test builds
Called program writing past caller storageParameter length mismatch corrupts WORKING-STORAGEPARMCHECK during testing and migration
Trusting COMMAREA, channel or map dataAn account number or role flag is taken from the screen or caller uncheckedRe-derive authority from the signed-on user ID (for example with EXEC CICS ASSIGN USERID) and server-side data
Missing ownership checksAny user who can run the inquiry transaction can read any customerCheck record ownership or branch scope in the program
Ignored SQLCODE and RESP valuesFailed security checks or SQL errors are treated as successCheck SQLCODE/SQLSTATE and RESP/RESP2 after every call
Credentials in source, JCL or PROCsPasswords for FTP, Db2 or partner systems in plain textPassTickets, 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), MQQUEUE and MXQUEUE (queues), MQPROC, MQNLIST, MXTOPIC, MQCMDS (commands) and MQADMIN or MXADMIN (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

  1. 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.
  2. Discover before enforcing: in a test region, turn on the missing X parameters and use security discovery statistics or ESM warning mode (RACF WARNING profiles) to see what would fail.
  3. Fix the highest exposure first: API-exposed transactions, dynamic SQL and default user access.
  4. Code review and scanning: search COBOL and JCL libraries for EXECUTE IMMEDIATE, string-built SQL, hard-coded passwords and unchecked RESP. Several SAST tools support COBOL; see the SAST Triage Guide.
  5. Test: include mainframe APIs and 3270 transactions in penetration tests, with authorisation testing for horizontal access (one customer reading another's data).
  6. 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 WARNING profile).
  7. 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=YES and all relevant X parameters 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

FrameworkReferenceMainframe application relevance
NIST SP 800-53 Rev. 5AC-3, AC-6CICS resource security, package owner privileges
NIST SP 800-53 Rev. 5SI-10, SA-11Input validation in COBOL; developer testing including compiler checks
NIST SP 800-53 Rev. 5CM-5, AU-12Who can BIND or change CICS definitions; SMF audit generation
NIST CSF 2.0PR.AA-05, PR.PS-06Least-privilege access; secure software development practices
OWASP ASVS 5.0V2.2.1, V8.2.1Positive input validation; function-level access for API-exposed transactions
ISO/IEC 27001:2022Annex A 8.28 Secure codingCOBOL coding standards and review
MITRE ATT&CKT1190, T1078.003Exploiting 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 XRES and 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=YES and review every X SIT 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 IMMEDIATE with static SQL or PREPARE with parameter markers; allow-list identifiers.
  • Bind packages under least-privilege owner IDs and review DYNAMICRULES.
  • Use SSRANGE, NUMCHECK and PARMCHECK in 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

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

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.