Stop Spammers from Using Your iSeries Mail Server
Q: We have just learned that someone has accessed our AS/400 and used our mail server to send spam. Based on what I have found on the forum and elsewhere, it appears that this is quite easy to do by Telnetting to port 25. Is there an easy way to shut this door?
A: Yes, and you should do so at once! Some spammer has discovered that your iSeries is acting as an open relay, and they are using your system and your domain name to obscure the true source of this spam. Given some of the vile content that can be contained in spam email, putting a fix in place has to be a paramount priority.
IBM has released two methods of limiting SMTP relays, and the method you should use depends upon the OS/400 release you're on. If you are at V4R5 or less, you'll need to perform the following steps:
- Create a source physical file called QUISRSYS/QTMSADRLST. IBM requires that the CCSID be equal to 500 so be sure to specify that parameter. Example: CRTSRCPF FILE(QUISRSYS/QTMSADRLST) CCSID(500).
Using your favorite source entry tool, create a member in that source file called ACCEPTRLY (Accept Relay).
- Add an entry into this source file (one per line) for each IP address or IP range that you wish to allow. Each entry can have up to two elements: The first element is an IP address, and the second element is the subnet mask. For example, if your internal TCP/IP addressing scheme is of the 192.168.* range, your first entry might look like this: 192.168.0.0 255.255.0.0. This mask will allow email relaying from all IP addresses from 192.168.0.0 through 192.168.255.255.
- If you want to allow some specific email address, tighten the subnet mask like so: 10.0.0.17 255.255.255.255.
The IBM Information Center also warns you to delete the data area called QUSRSYS/QTMSNORLY after you've created this source file. That data area prevents all email relay, something you might not want to do.
For versions less than V4R5, you will have to load a PTF to enable this relay constraint. The PTFs and their respective OS releases are as follows:
- V4R2 5769TC1 SF52864
- V4R3 5769TC1 SF53421
- V4R4 5769TC1 SF54014
If you're at V5R1 though, IBM has made things a bit easier for you. You need only issue the CHGSMTPA command and specify that you would like to limit SMTP relay to a predefined list of TCP/IP addresses. That command would look like this: CHGSMTPA ALWRLY(*LIST).
Then, use the ADDSMTPLE command (and its corresponding RMVSMTPLE command) to manage the TCP/IP addresses that should be allowed to relay email through your AS/400.
Q: Can you tell me how to set up ODBC security on our AS/400? Is an exit program the only way to do this?
A: Well, an exit program is not the only way, but it is often the most effective and efficient way to implement security on iSeries machines that have traditional security models. And to be clear, ODBC in and of itself does not represent a security exposure, but rather it (and other network access points such as FTP, DDM, etc.) allows your users to exploit an existing security exposure that plagues most iSeries installations.
ODBC brings your pre-existing security problem into sharper focus. At the heart of the matter is whether an end user has OS/400 object level authority to data. ODBC cannot magically grant access when a user requests to read or change data through PC applications such as Microsoft Excel. The ODBC driver used by Excel is required to present a user's OS/400 credentials to your operating system, and the operating system will still insist that the user has proper authority before granting access to your data. But if you are running a typical OS/400 application, your application users have *ALL rights to the data by virtue of their membership in some powerful group profile. In our security practice, we often find that the general public (*PUBLIC) has at least *CHANGE rights to application data. If this is the case in your shop, you have two basic routes you can go: Rearrange your fundamental security model or install network security exit programs.
If you have the time, resources, and enough detailed knowledge of your software package to rearrange your security model, you will want to focus on five primary areas of improvement: exclude based posture, proper ownership, meaningful group profile(s), objects secured by authorization lists, and program authority adoption.
The exclude based posture means that you will remove every user's individual access to all of the data, and then you'll change *PUBLIC's authority to *EXCLUDE on every file. This step is designed to refuse any attempted access to your data except as defined by you in the steps below.
Once the general public is properly excluded from the application, you should look to setting proper ownership of your application objects. Do this by creating a series of special owner user profiles. One profile will own (nearly) all of the objects in the application (the application owner profile). For future reference, let's call the set of objects owned by this user Object Set A. Next, create a series of application administration profiles that will be used to give certain users access to the application. These application administration profiles are not assigned to real users; each will own a small number of programs that will be used in an adopted authority scheme. More on that later. For future reference, the objects that are owned by these profiles will be referred to as Object Sets B through n. These application administration user profiles will roughly match your application group profiles (described later) on a one-to-one basis. These new special owner and administrator user profiles do not need passwords or any special authorities, nor should they be group profiles for any other system user. Their primary purpose is to own the application objects.
To create meaningful group profiles, you will want to segregate your existing users into distinct group profiles that can be secured to specific job functions. Logical groups of users in an organization might include AP personnel, AR personnel, shipping dock workers, order entry operators, payroll staff, department supervisors, senior managers, and so on. The general idea here is to tightly scope the job function so that a group of users can be given very specific action rights. Create the group profiles with meaningful names and assign each user to at least one group. In some cases, you will need to assign a user to more than one group (the payroll supervisor, for example might belong to both the Payroll Group and the Supervisor Group), but that won't be a problem because group profile authority in OS/400 is cumulative.
Once the group profiles and are set, you'll want to set two authorization lists to secure all of the objects in Object Set A. All of the data elements should be secured by one authorization list, and all of the programs (and other static, non-changing objects) should be secured by the second authorization list. Next, grant the *PUBLIC *EXCLUDE authority to both lists, and grant all of the application administration user profiles *CHANGE authority to the data authorization list and *USE authority to the program authorization list. To complete this step, you will secure each of the Object Sets (B through n) with their corresponding authorization list. Again, *PUBLIC will have *EXCLUDE authority to the objects on this list.
Finally, you can tie this whole scheme together by granting the various group profiles *USE authority to the corresponding adopted authority programs.
This way, when your users attempt to run your applications, the flow will go something like this:
- Mary belongs to the group profile OrderEntry.
- The group profile OrderEntry has *USE right to the program OE01 through the authorization list that secures program OE01.
- When program OE01 is called, it adopts the authority of application administration user profile OEADMIN.
- Application administration user profile OEADMIN has *CHANGE rights to the data in the application and *USE rights to the programs and other static objects in the application.
- When Mary chooses a menu option that attempts to update the Order Entry file, she is allowed to because her job is adopting the authority of user OEADMIN.
- If Mary attempts to read the Order Entry file using ODBC, she is denied access because neither user profile Mary nor group profile OrderEntry has any direct authority to the file.
This security model is quite secure, but if you're tempted to write to me and tell me it is too confusing, too difficult to implement on software packages that you purchased, or not workable because some of your users need read or update rights to some of your data via ODBC, save the electrons; I wholeheartedly agree.
This is why most OS/400 shops elect to use exit programs to secure network access from PC applications. Exit programs have the advantage of being simpler to implement (especially if you purchase them rather than try to write them yourself) and less disruptive than a complete security re-org.
With exit programs at the FTP, ODBC, and other various network interfaces, you can quickly take an exclude based posture. That is, exclude *PUBLIC from using the ODBC server at all, and then, if necessary, allow certain users to have just read access. You can even provide limited data update rights to your data if you have users who you trust to do that.
So, no, an exit program is not the only way to secure data from ODBC, but unless you have a lot of time on your hands, it's likely the best way.
Authority to Delete Device Descriptions
Q: We are on an AS/400 Model 820 with V5R1. Apparently in V5R1, *IOCFGSYS and *JOBCTL authority will not let you delete virtual devices and controllers automatically created by QSYS. We have created a CL program that adopts authority, but it gives us a command line. Is there a way to restrict that command line, in CL, just for that call? When F3 is pressed, I'd like my command line back.
A: I don't know that this is a change to V5R1; it is more likely something has changed in the way your users are authorized to the virtual device objects. In order to delete an object (any object) you have to have Object Existence (*OBJEXIST) rights to that object. Sure, *IOSYSCFG special authority is required to work with communications objects like virtual devices, and it makes sense that in certain circumstances you'll need *JOBCTL special authority in order to end a job that could be attached to the device description, but neither of those special authorities will give you the specific right to delete a device description object.
To solve your problem, consider putting all of your existing virtual devices into an authorization list and then authorizing selected users to delete the objects in that authorization list. Then, when new virtual devices are created by something like Telnet, the new device will assume the authority properties of the old device (including the authorization list), and your administrators will have the requisite authority to delete them.
Also, rather than give these users a command line that adopts widespread authority, consider using a more tightly scripted adopted authority routine that does exactly what you want--and only what you want. A three-line CL program with selective prompting like the one below can be used to adopt authority and only permit a single action, surely a better option than the unrestricted command line prompt.
Try the command at a selective command prompt at a command line and see how it works.