This means that network access to databases is now critical, particularly for electronic commerce applications where database servers and web servers need to exchange data. We have discussed issues about locating database servers and web servers in Chapter 15, "The World Wide Web". Here, we will discuss the protocols used to provide network access and their security implications.
You can reduce this vulnerability by carefully configuring the access that the web server has. You should use all of the access controls that your database server provides to make certain that the web server can do only things that it's supposed to be able to do. Don't use a generic database account that has many permissions. Instead, set up the web server to use a specific database account that can access only necessary data. If at all possible, set it up to use stored procedures so that it does not have access to the arbitrary database commands but can only do predefined operations that are stored as part of the database.
The amount of additional security you can get this way depends a great deal on what the web site is supposed to do. If web users are only able to read data, you may be able to get pretty good protection from the database security. On the other hand, if the web site allows people to order things, cancel their orders, or otherwise modify data, an attacker who compromises the web server is going to be able to really make you suffer, no matter what the database security is like.
We recommend building your protocol on top of an existing message-passing mechanism, but only if it provides the necessary access controls. It may be tempting to use HTTP, but we recommend against it for a number of reasons. First of all, HTTP is connectionless, which makes it difficult to build something that is transaction based and robust. Second, it means that you will have to run CGI or an equivalent on an internal HTTP server. This then makes it equivalent to an architecture we recommend against.
Building a custom protocol is not always practical. It assumes that you have local programming talent sufficient to write a small but secure client/server application. Creating a secure client/server application is not easy, so implementing the communications yourself may simply introduce different security problems from those you would have been exposed to if you'd used the database vendor's communication package. Implementing it yourself also has long-term maintenance ramifications. Nevertheless, on balance this method has significant advantages.
There is a great deal of confusion about ODBC. If you are on a machine that uses ODBC and you are trying to configure the machine to talk to a database across a network, you will usually go through the process of configuring something called an ODBC driver. This causes many people to believe that the driver is actually part of ODBC and that ODBC controls what options are in it, which is not the case. The ODBC driver is specific to the database you are talking to, not to ODBC; it is the driver that makes ODBC talk to your database, and it is provided by the database vendor. ODBC itself does not control the network communications and has no firewall characteristics. ODBC applications do not have to use the network at all; ODBC may be used to talk to a database running locally on the same machine.
JDBC is simply the Java analog to ODBC, a Java API that will connect to any of a variety of vendor database drivers. Because JDBC is based on Java, which is designed to be dynamically loaded, it allows clients to dynamically load the needed drivers, while in ODBC, they have to be explicitly installed. As usual, this increases convenience at the cost of security.
If you are asked to allow ODBC or JDBC through a firewall, you should ask what database is being used and research the network characteristics of that particular database. ODBC and JDBC by themselves will not change those characteristics. (Occasionally, databases that offer multiple connection options may not offer ODBC or JDBC drivers for all the options. Again, this is determined by the database developer and is not inherent to ODBC or JDBC.) If you have no further information to work from, assume that people who ask for ODBC really want to use Microsoft SQL Server, since it is the database most closely associated with platforms that run ODBC.
SQL*Net and Net8 are both based on Oracle's Transparent Network Substrate (TNS) and will attempt to speak to a server known as a TNS listener. Oracle's network situation is further complicated by the fact that it provides its own naming service, Oracle Names, which has its own server. Some proxying services are provided by Oracle Connection Manager in Oracle8 and the Oracle Multiprotocol Interchange server in Oracle7.
Encryption is actually handled by TNS, but Oracle doesn't provide TNS versioning information. In the TNS version built into SQL*Net v1, nothing is encrypted, not even user authentication. Passwords are sent across the network not only reusable but unprotected and in the clear. As of SQL*Net v2, user authentication and TNS listener control passwords are protected but reusable when passed across the network. As of Net8/Oracle8, Oracle Names uses a protected control password as well.
The Oracle Advanced Networking Option (ANO) provides data stream encryption (via 40-bit RC4 or DES internationally, 56-bit RC4 or DES or 128-bit RC4 within the United States) and MD5 message digests. It also provides support for nonreusable passwords. Oracle also has a separate Security Server product that is used to provide an API for explicit data signing and signature verification at the application level -- a normal Oracle application cannot control whether or not the client and server are using Advanced Networking's encryption features. An Oracle server, however, may choose to require encryption and/or checksumming on all connections.
Oracle has had many security problems with their server installations. Most of these problems have involved ways to turn access to the server machine into root access or Oracle administrator access, using Oracle tools. However, some problems (like the denial of service problems previously mentioned) were exploitable from the network.
[165]People are often confused by the IANA registrations for ports 66 and 140, which have "sql" and "net" in their names but are not used by Oracle. They are historical curiosities left over from previous theories about networked SQL.
Direction | SourceAddr. | Dest.Addr. | Protocol | SourcePort | Dest.Port | ACKSet | Notes |
---|---|---|---|---|---|---|---|
In | Ext | Int | TCP | >1023 |
1575[166]
|
[167]
|
Name lookup, external client to internal server |
Out | Int | Ext | TCP | 1575[166] | >1023 | Yes | Name response, internal server to external client |
In | Ext | Int | TCP | >1023 |
1600[168]
|
[167] | Request, external client to internal server (using Connection Manager) |
Out | Int | Ext | TCP | 1600[168] | >1023 | Yes | Response, internal server to external client (using Connection anager) |
In | Ext | Int | TCP | >1023 |
1521[169]
|
[167] | Request, external client to internal server (using TNS) |
Out | Int | Ext | TCP | 1521[169] | >1023 | Yes | Response, internal server to external client (using TNS) |
In | Ext | Int | TCP | >1023 |
1526[170]
|
[167] | Request, external client to internal server (using Multiprotocol Interchange) |
Out | Int | Ext | TCP | 1526[170] | >1023 | Yes | Response, internal server to external client (using Multiprotocol Interchange) |
In | Ext | Int | TCP | >1023 |
>1023[171]
|
[167] | Redirected request, external client to internal server |
Out | Int | Ext | TCP | >1023[171] | >1023 | Yes | Response to redirected request, internal server to external client |
Out | Int | Ext | TCP | >1023 | 1575[166] | [167] | Name lookup, internal client to external server |
In | Ext | Int | TCP | 1575[166] | >1023 | Yes | Name response, external server to internal client |
Out | Int | Ext | TCP | >1023 | 1600[168] | [167] | Request, internal client to external server (using Connection Manager) |
In | Ext | Int | TCP | 1600[168] | >1023 | Yes | Response, external server to internal client (using Connection anager) |
Out | Int | Ext | TCP | >1023 | 1521[169] | [167] | Request, internal client to external server (using TNS) |
In | Ext | Int | TCP | 1521[169] | >1023 | Yes | Response, external server to internal client (using TNS) |
Out | Int | Ext | TCP | >1023 | 1526[170] | [167] | Request, internal client to external server (using Multiprotocol Interchange) |
In | Ext | Int | TCP | 1526[170] | >1023 | Yes | Response, external server to internal client (using Multiprotocol Interchange) |
Out | Int | Ext | TCP | >1023 | >1023[171] | [167] | Redirected request, internal client to external server |
In | Ext | Int | TCP | >1023[171] | >1023 | Yes | Response to redirected request, external server to internal client |
[166]1575 is a popular default, but this may be set to any port number.
[167]ACK will not be set on the first packet (establishing connection) but will be set on the rest.
[168]1600 is a popular default, but this may be set to any port number.
[169]1521 is a popular default, but this may be set to any port number.
[170]1526 is a popular default, but this may be set to any port number.
[171]This port is dynamically assigned by the server.
Oracle provides a product called Oracle Connection Manager that will provide proxying, among other things, for SQL*Net and Net8 clients. Oracle Connection Manager provides extremely limited control over what clients can connect; you can accept or deny based on the following:
Destination host or IP address
Destination port
Destination database name
TDS is a straightforward TCP-based protocol, in which the client starts up a single connection to the server. No fixed port is used by TDS, and different implementations default to using different port numbers. In its simplest form, TDS transmits all data, including usernames and passwords, unprotected and in the clear. However, some TDS implementations use encryption to protect all or part of the data. All in all, knowing that a product uses TDS tells you relatively little about its security and firewalling implications, although the information does tend to suggest that it will be relatively straightforward to pass through a firewall (it does not tell you whether or not that would be a good idea, since TDS may be cleartext or encrypted).
Direction | SourceAddr. | Dest.Addr. | Protocol | SourcePort | Dest.Port | ACKSet | Notes |
---|---|---|---|---|---|---|---|
In | Ext | Int | TCP | >1023 |
7878[172]
|
[173]
|
Request, external client to internal server (using TDS) |
Out | Int | Ext | TCP | 7878[172] | >1023 | Yes | Response, internal server to external client (using TDS) |
In | Ext | Int | TCP | >1023 |
8080[174]
|
[173] | Request, external client to internal server (using HTTP) |
Out | Int | Ext | TCP | 8080[174] | >1023 | Yes | Response, internal server to external client (using HTTP) |
In | Ext | Int | TCP | >1023 |
8001, 8002[175]
|
[173] | Request, external client to internal server (using HTTPS) |
Out | Int | Ext | TCP | 8001, 8002[175] | >1023 | Yes | Response, internal server to external client (using HTTPS) |
In | Ext | Int | TCP | >1023 |
9000[176]
| [173] | Request, external client to internal server (using IIOP) |
Out | Int | Ext | TCP | 9000[176] | >1023 | Yes | Response, internal server to external client (using IIOP) |
In | Ext | Int | TCP | >1023 |
9001, 9002[177]
|
[173] | Request, external client to internal server (using IIOPS) |
Out | Int | Ext | TCP | 9001, 9002[177] | >1023 | Yes | Response, internal server to external client (using IIOPS) |
Out | Int | Ext | TCP | >1023 | 7878[172] | [173] | Request, internal client to external server (using TDS) |
In | Ext | Int | TCP | 7878[172] | >1023 | Yes | Response, external server to internal client (using TDS) |
Out | Int | Ext | TCP | >1023 | 8080[174] | [173] | Request, internal client to external server (using HTTP) |
In | Ext | Int | TCP | 8080[174] | >1023 | Yes | Response, external server to internal client (using HTTP) |
Out | Int | Ext | TCP | >1023 | 8001, 8002[175] | [173] | Request, internal client to external server (using HTTPS) |
In | Ext | Int | TCP | 8001, 8002[175] | >1023 | Yes | Response, external server to internal client (using HTTPS) |
Out | Int | Ext | TCP | >1023 | 9000[176] | [173] | Request, internal client to external server (using IIOP) |
In | Ext | Int | TCP | 9000[176] | >1023 | Yes | Response, external server to internal client (using IIOP) |
Out | Int | Ext | TCP | >1023 | 9001, 9002[177] | [173] | Request, internal client to external server (using IIOPS) |
In | Ext | Int | TCP | 9001, 9002[177] | >1023 | Yes | Response, external server to internal client (using IIOPS) |
[172]7878 is the default, but this may be set to any port number.
[173]ACK will not be set on the first packet (establishing connection) but will be set on the rest.
[174]8080 is the default, but this may be set to any port number.
[175]8001 and 8002 are the defaults, but this may be set to any port number.
[176]9000 is the default, but this may be set to any port number.
[177]9001 and 9002 are the defaults, but this may be set to any port number.
icrosoft SQL offers multiple options for user authentication. If you set it to use SQL authentication over TDS, it passes authentication data over the network in cleartext. If you set it to use Windows NT authentication over TDS, the username and password data is obscured. (It is not clear what this is, but it appears to be reversible encryption rather than challenge-response.) SQL authentication over TDS does not protect username and password data and should never be used in an insecure environment.
You should be careful about what accounts you use for SQL access. They should have the minimum necessary permissions on the SQL database and under Windows NT. They should not be accounts that are used for logins or file sharing under Windows NT.
Note that if a client attempts to use SQL authentication across an insecure network, and the server is set up to use Windows NT authentication, the authentication will fail, but the account will still be compromised. The client will send the cleartext username and password, which can be intercepted, and there is no way for the server to prevent it.
Some versions of Microsoft SQL Server support database replication only over SMB; more recent versions will allow database replication over TDS, but it is less efficient.
Direction | SourceAddr. | Dest.Addr. | Protocol | SourcePort | Dest.Port | ACKSet | Notes |
---|---|---|---|---|---|---|---|
In | Ext | Int | TCP | >1023 |
1433[178]
|
[179]
|
Request, external client to internal server |
Out | Int | Ext | TCP | 1433[178] | >1023 | Yes | Response, internal server to external client |
Out | Int | Ext | TCP | >1023 | 1433[178] | [179] | Request, internal client to external server |
In | Ext | Int | TCP | 1433[178] | >1023 | Yes | Response, external server to internal client |
[178]1433 is the default, but this may be set to any port number.
[179]ACK will not be set on the first packet (establishing connection) but will be set on the rest.