The KeyStore API is code complete. Check it out at phpkeystore.org. The current development release can always be installed with PEAR using:
pear install http://phpkeystore.org/download/KeyStore-current.tgz
All that really remains right now is internal tweaking for best practices and performance.
To summarize the functionality, the key management functionality consists of:
- Loading and storing the key store
- Creating secret keys, certificate signing requests, importing signed certificates, and deleting key store entries
- Querying the key store for the existence of an entry and what type of entry it is
And the key usage functionality consists of:
- Loading the key store
- Using a public/private key pair to encrypt, decrypt, sign, and verify
- Using a secret symmetric key to encrypt and decrypt
The current to-do list:
- Add configuration file for system default values
- Support file-based passwords
- Support user-supplied options on the interface methods in order to support cryptographic functionality other than the default, baked-in settings
- Add failure-case unit tests
- Code review
The following forty five (45) Internet/network security gotchas are taken from Firewalls and Internet Security – Repelling the Wily Hacker, Second Edition (ISBN: 0-201-63344-X) by William R. Cheswick, et. al.
- IP source addresses aren’t trustable.
- Fragmented packets have been abused to avoid security checks.
- ARP-spoofing can lead to session-hijacking.
- Sequence number attacks can be used to subvert address-based authentication.
- It is easy to spoof UDP packets.
Redirect messages can subvert routing tables.
- IP source routing can address-based authentication.
- It is easy to generate bogus RIP messages.
- The inverse DNS tree can be used for name-spoofing.
- The DNS cache can be contaminated to foil cross-checks.
- IPv6 network numbers may change frequently.
- IPv6 host addresses change frequently, too.
- WEP is useless.
- Attackers have the luxury of using nonstandard equipment.
- Return addresses in mail aren’t reliable, and this fact is easily forgotten.
- Don’t blindly execute MIME messages.
- Don’t trust RPC‘s machine name field.
- Rpcbind can call RPC services for its caller.
- NIS can often be persuaded to give out password files.
- It is sometimes possible to direct machines to phony NIS servers.
- If misconfigured, TFTP will had over sensitive files.
- Don’t make ftp‘s home directory writable by ftp.
- Don’t put a real password file in the anonymous ftp area.
- It is easy to wiretap telnet sessions.
- The r commands rely on address-based authentication.
- Be careful about interpreting WWW format information.
- WWW servers should be careful about URLs.
- Poorly written query scripts pose a danger to WWW servers.
- The MBone can be used to route through some firewalls.
- Scalable security administration of peer-to-peer nodes is difficult.
- An attacker anywhere on the Internet can probe for X11 servers.
- UDP-based services can be abused to create broadcast storms.
- Web servers shouldn’t believe uploaded state variables.
- Signed code is not necessarily safe code.
- [Client-side script] is dangerous.
- Users are ill-equipped to make correct security choices.
- Humans choose lousy passwords.
- There are lots of ways to grab
- There is no absolute remedy for a denial-of-service attack.
- Hackers plant sniffers.
- Network monitoring tools can be very dangerous on an exposed machine.
- Don’t believe port numbers supplied by outside machines.
- It is all but impossible to permit most UDP traffic through a packet filter safely.
- A tunnel can be built on top of almost any transport mechanism.
- If the connection is vital, don’t use a public network.
Designing applications for the web requires an up-front security mind-set. It does not matter if the application takes credit card payments or if it hosts static web content. A public web site is just that: a public portal to computer assets that someone out there on the Internet will eventually find and will want to exploit for whatever nefarious reason entertains their interests, whatever it is.
The purpose of this post is to discuss the web application design and architecture security truisms that I have held true during my experience as a developer and architect. The following fifteen (15) security truisms are taken from Firewalls and Internet Security – Repelling the Wily Hacker, Second Edition (ISBN: 0-201-63344-X) by William R. Cheswick, et. al. These truisms are key to any security model – not just information security. For the purposes of this post, I will discuss how they relate to application design and architecture.
- There is no such thing as absolute security. Any web application deployed to a network, be it publicly on the Internet, internally on an Intranet, or even privately on an extranet, will not be absolutely secure. This is due to the fact that it is connected to a network – the level of it’s security has been diminished purely by it’s nature of been deployed. This is a fact.
- Security is always a question of economics. The amount of security that a web application design employs is dependent upon the amount of security infrastructure the application owner is willing to pay for. Though tighter security can be bought with hardware cryptography, LDAP servers, etc., it’s always a question of cost vs. how much risk the application owner is willing to accept. In the end, it’s a question of balance.
- Keep the level of all your defenses at the same height. This is a tricky one that many people overlook – balance. The level of an application’s should balance the level of security of the environment in which it is being deployed. This includes, but is not limited to, the level of physical and software firewall protection, the amount and type of intrusion detection systems, etc. It doesn’t make a lot of sense to blow out the security architecture of a web application if it’s going to be deployed in your brother’s basement on his Wi-Fi router. Conversely, it makes equally less sense to deploy a an insecure web application in a shared hosting environment that hosts credit card payment applications.
- An attacker doesn’t go through security, but around it. The web application should not be designed as another security hole in the web site’s security! Attackers will look for weaknesses in web applications deployed to a web site and exploit them.
- Put your defenses in layers.
- It’s a bad idea to rely on “security through obscurity.” Compiling the password into the source code, believing it won’t be found because it has been “obscured”, is stupid. I’m sorry, I said it. I’ve seen it done before. Put hope in the cost/benefit of hiding secrets in plain site will only reek havoc in the end.
- Keep it simple. Cleaner, well documented code is easier to maintain. Easier maintained code is even easier to secure.
- Don’t give a person or a program any more privileges than those necessary to do the job. Developers don’t need access to secured resources. The exception is source code repositories, development databases, development LDAP servers, etc. Web applications should be deployed by deployers, not developers. The production authentication credentials should be provided to system administrators that set up the web application server infrastructure. A truly well designed application architecture will not require a developer or deployer to know the production authentication credentials of protected resources such as databases, LDAP servers, or hardware key stores.
- Programming is hard. Secure programming is harder. Don’t make the job harder than it needs to be. Use common components commonly accepted by the global development community. Don’t reinvent the wheel by rewriting cryptography algorithms. Reuse code and see #7.
- Security should be an integral part of the original design.
- If you do not run a program, it does not matter if it has security holes. If you do not deploy a web application, it does not matter if it is insecure. However, no one will be able to access it.
- A program or protocol is insecure until proven secure. Run web application vulnerability scanning tools. You will be surprised what you will find – and what you will learn about secure programming practices.
- A chain is only as strong as its weakest link. Our hosting environment can provide us with the strongest firewalls and intrusion detection systems. However, we are writing software, too. The software we write is just one more link the chain. That link must be designed as strong as the rest of the links in chain.
- Security is a trade-off with convenience. And, as security often inconveniences users, the application owner will often feel inconvenienced by higher levels of security. This is where discussions on “single-sign-on” begin. For any given company, a users will want to sign-in to the web site once. To sign-in again will be an inconvenience. To have to remember more than one password is even more inconvenient. Ergo, without a “single-sign-on” solution in place, users will feel inconvenienced if they have to sign-in every time the visit a different web site that requires authentication for a given company.
- Don’t underestimate the value of your assets. Just because the web application does not perform secure payment transactions does not mean that it isn’t attractive to attackers. Any computer resource on the Internet can be used as a host for an attack for whatever reason.
All this being said, secure web application design is possible, affordable, and necessary. It must be thought out and balanced against the needs of the application owner and deployment environment. As technology professionals, we are all responsible for the web applications that we design, implement, and deploy because, as any software being run in a remote hosting environment, we provide the gateway between our computer assets and the world wide web.