The recent news that the popular dating site Plenty Of Fish was hacked and that passwords and other user information was stolen truly disheartened me.
It was just the latest in a seemingly endless list of such hacks over the years, recently including Gawker Media (Lifehacker, Gizmodo), McDonald's, Walgreen's and Pizza Hut.
Apparently, Little Bobby Tables is alive and well.
What is disheartening to me is not so much the security breaches themselves. No site is completely secure. The operators of these and other sites may have been able to do more than they did to prevent the breaches, or maybe they had really good (but not good enough) security. But security breaches will happen. I think that every site has to assume that it is possible that their site will be hacked and their database stolen.
I'm not suggesting that they just accept the inevitable, and give up. I'm suggesting that everyone that builds a website that collects information from their users (that's every site that has user accounts) should care enough to do their best to ensure that when the site is compromised, the damage is as minimal as possible. That's why the Plenty Of Fish hack was so disturbing. Passwords were apparently stored in the database in clear-text. Once the database was stolen, passwords were readily available, with no further work on the hacker's part.
I had thought that clear-text passwords were such a well-known evil that no-one was doing it any more, but apparently I was mistaken. Web developers who don't know any better apparently still store plain-text passwords so that they can implement the even less-secure feature of emailing it to you if you forget it (or even sometimes even if you don't).
So, what's the right thing to do? Obviously, the most important prerequisites are being aware of the problem, and caring enough about your users to do something about it. If you've read this far, I'll assume that you have those two covered.
The next thing is to not store passwords. Let me repeat that - do not store your user's passwords. By that, I do not mean that you should encrypt the passwords before you store them, though that would be a huge improvement over plaintext. The problem with storing encrypted passwords is twofold. The first, as previously mentioned, is that it may tempt you to decrypt it for some reason (like sending it to the user in an email). The second problem is that unless you are really careful with your encryption, the data thief may very well have the resources to decrypt the passwords.
Instead of storing a user's password, store a cryptographic hash of their password. A cryptographic hash is also known as a one-way hash, and cannot be "decrypted". For authentication, take the user-entered password, run it through the same hash function, and then compare the result to the hash stored in the database. Provide users with the means to securely re-set their password (choose a new one) in the event that they forget it, rather than attempting to send them the old one.
There are still some issues to be aware of when using cryptographic hashes. If there are collisions (two different passwords hash to the same value), and the thief possesses one of the clear-text passwords by some other means, then they can substitute the known password for the one in the other account. Of course, there's always the possibility that two or more users will pick the same password. For example, in the Gawker Media case, the password data was published on the web, and it was revealed that thousands of users had chosen the same few passwords, with '123456' and 'password' leading the list. If you use a simple hash function, then it seems likely that you will have lots of collisions. This makes several attack vectors, like a dictionary attack, or other brute-force attack much more likely to be successful.
The answer to collisions is random salt. By appending random bits to the password before hashing it, you can make the hashes much more likely to be unique. A common method is to generate a new, random salt value for each user, and to store the salt in an additional column in the password table. Making the salt available to a hacker does not make the hashes more susceptible to a brute-force attack if no two of the salt values are the same. One thing to be careful of is using the username for salt - unless you intend to never let a user change their username.
All hash functions are not created equal. As time goes on, and more and more computing power becomes available at relatively low cost, once-unbreakable hash functions become breakable. For instance, SHA-1, apparently still the most widely used cryptographic hash function, was broken in 2005, and the National Institute of Standards and Technology has recommended that federal agencies stop using it. SHA-2, the recommended replacement for SHA-1, while not yet broken, has already been recognized by NIST as potentially insecure, and there is already an effort under way to develop SHA-3.
One-way, randomly-salted SHA-2 (or eventually SHA-3) hashes should solve your password security issues, but what about other user data? What about email addresses, credit card numbers, and the like? I'd like to suggest that the first line of defense is collecting as little sensitive information as possible. Storing credit card information (where legal) is generally unnecessary and provides the potential attacker with substantial incentive. In short, unless you are a credit card company, you probably shouldn't store credit card information.
Other user information should be treated just as carefully - stored only if absolutely necessary, and stored with encryption as secure as possible if it must be stored. Assume from the start that your database will be compromised, and make it as difficult as possible for the data to be used.
There are many other security issues to be concerned about, and I encourage you to research them, but if you care about your users and your reputation, then the least you can do is stop storing sensitive user information in the clear.
Tuesday, February 1, 2011
Executing JavaScript from Objective-C in an iOS App
New blog post from Steve Smith, one of the Chariot architects working in our mobile practice. Steve is currently working on updating the mobile app for our Emerging Technologies conference and will be posting articles from time to time as he finds challenges or discoveries.
Here is an excerpt:
The other day, I found the need to execute some JavaScript from a native iOS application. After doing a little research, I discovered that the UIWebView has a stringByEvaluatingJavaScriptFromString method. So I decided to create a quick little proof-of-concept to see how to invoke some JavaScript using this. I am not going to walk through all the details of creating a project, etc. and will cut right to the important aspects of making the JavaScript call from the objective-c code.
We are going to need a JavaScript function to call and a UIWebView to evaluate the JavaScript. It would be nice if the JavaScript function took a parameter as well, so we could also prove out the passing of values. Here is the JavaScript function that I will use:
Read more
Here is an excerpt:
The other day, I found the need to execute some JavaScript from a native iOS application. After doing a little research, I discovered that the UIWebView has a stringByEvaluatingJavaScriptFromString method. So I decided to create a quick little proof-of-concept to see how to invoke some JavaScript using this. I am not going to walk through all the details of creating a project, etc. and will cut right to the important aspects of making the JavaScript call from the objective-c code.
We are going to need a JavaScript function to call and a UIWebView to evaluate the JavaScript. It would be nice if the JavaScript function took a parameter as well, so we could also prove out the passing of values. Here is the JavaScript function that I will use:
1 | var area = function(diameter) { |
2 | var radius = diameter/2, |
3 | area = Math.PI * radius * radius; |
4 | return Math.round(area*100)/100; |
5 | }; |
Read more
Monday, January 24, 2011
Android Development: Best Practices
Thanks to Anatoly Polinsky for another blog post
I got introduced to an Android application development during Philly ETE conference by listening to “A guided tour of the Android ETE mobile application” talk, where Andrew Oswald ( a Java Architect from Chariot Solutions ) talked about creating an Android app for the conference, which was a cool introduction to “what it takes” to write one of those apps from scratch. I am looking forward to more talks around mobile development this year at Philly ETE conference as well.
Meanwhile I rely mostly on Android’s Developer Guide whenever I seek answers to my questions or/and best practices. Here are my notes on such practices I picked up listening to “A Beginner’s Guide to Android” Google I/O 2010 talk:
Read More....
I got introduced to an Android application development during Philly ETE conference by listening to “A guided tour of the Android ETE mobile application” talk, where Andrew Oswald ( a Java Architect from Chariot Solutions ) talked about creating an Android app for the conference, which was a cool introduction to “what it takes” to write one of those apps from scratch. I am looking forward to more talks around mobile development this year at Philly ETE conference as well.
Meanwhile I rely mostly on Android’s Developer Guide whenever I seek answers to my questions or/and best practices. Here are my notes on such practices I picked up listening to “A Beginner’s Guide to Android” Google I/O 2010 talk:
Read More....
Tuesday, January 18, 2011
Enterprise Integration with Spring Training
Are you a Spring Developer?
Do you have Enterprise solutions to develop or architect?
Chariot Solutions, a Spring Training Partner and Philadelphia leader in Spring Training, Mentoring and Consulting can help you take your Spring skills to the next level - Enterprise Integration!
There are many Spring developers who have learned by experimenting, reading documentation and maybe code dives into an existing application or two. But with the knowledge you gain from Official SpringSource training at Chariot from our certified SpringSource instructors, you can be more equipped to chose the right tools for your complex integration solutions.
The Enterprise Integration with Spring (EIwS) course is not only extremely valuable to any Spring developer it should be REQUIRED for anyone architecting Spring applications.
What is cool in the EIwS course?
- Synchronous & Asynchronous Processing
- Messaging with Enterprise Integration Patterns
- Messaging with JMS
- Exposing Services with RMI, HTTP
- Web Services with SOAP, REST and WS Security - and why REST is cool!
- Spring Local and Distributed Transaction Management - JTA/XA - Open Source distributed transactions without a JEE Server
- Service Integration with SMTP (email), File, JMS, FTP, JDBC, TCP/UDP, XMPP, etc.
- Polling and Triggering
- Tasks and Scheduling of Processes
- Message Filtering, Routing, Transformation, Splitting, Aggregating, Bridging and Chaining
- Creating Batch processes for inline or offline execution
- Monitoring Batch process exceptions
- Unit and Mock testing of application layers
- Modifying Integration processes without recompiling... AWESOME Right?
One of the key take-aways from this course is knowing which tools are available to choose from and why.
What does Gordon teach?
When I teach the Core or EIwS classes, I go through the common Spring project application layers, and their respective roles and responsibilities. We discuss the tools you have within Spring and which to use to solve integration concerns. In EIwS, the course builds from common concurrency, tasks & scheduling, Messaging with JMS to the flexible power of Spring Integration and Spring Batch tool sets. I teach layering your applications focussing on the power and flexibility of Service POJOs exposing your processes in a Service Oriented Architecture (SOA) manner and keeping your POJOs - Pure business objects, un-compromised by framework or infrastructure java objects.I am teaching EIwS February 22-25, 2010 in Philadelphia! If you come you will receive:
- A shiny new course book
- An Official Spring USB thumb drive with SpringSource Tool Suite, Course Documentation PDF, all the labs & solutions
- The secret meaning of the acronym "SOA"
- Bad humor from your instructor (if I teach you can count on it)
- Demo's that Gordon creates (if taking my class)
- Lunch, Coffee, Tea & soft drinks
Q&A
Q: What if I have not taken the Core Spring course?
A: It is highly recommended that you attend the Core Spring Course first. Click here to see the Course Schedule
Q: What if I am not using Spring 3 yet?
A: No problem, although the course focuses on 3.0 features, you will still get usable information for your applications.
Q: What will I learn?
A: Scroll up.
Q: What if I already have used some of the topics covered?
A: Relax during those chapters or, even better, provide your "in the trenches" experience with the class.
Q: How can I get management to pay for the class?
A: This course is Essential to my skills, to provide you with better tools to choose the right approach to solving our complex integration needs. Check Here for possible Early Bird Discounts.
Q: Where do I find out about the Enterprise Integration course?
A: Click here for SpringSource Training Site
Q: When is Gordon teaching the class?
A: Click here for the next scheduled course on February 22, 2011
Q: Is there certification for Enterprise Integration Specialist?
A: Check here for the status on Enterprise Integration Specialist Certification
Memorable Quotes:
- "Wow, I just learned in 5 minutes what it took me 2 weeks to do in the past"
- "A Spring Developer without
- "Understanding the layered design of Spring applications really helps me best architect my solutions."
- "I really needed to provide file processing into my database, glad I took this class for those implementation discussions"
So, what are you waiting for? Register NOW for Enterprise Integration with Spring!
Monday, January 17, 2011
Simple Spring Social for Twitter Friends
The Spring Social project provides us developers with an easy way to interact with Twitter, Facebook, LinkedIn & TripIt via the familiar Template objects we have used. Spring has provided Templates for convenient interaction with JDBC, REST, Hibernate, JNDI, and more.
One of the simplest social media calls is to lookup someone's Twitter friends with the TwitterTemplate.
1. Add the Spring Social project dependency to the pom.xml file
<dependencies>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>${spring.social.version}</version>
</dependency>
...
</dependencies>
2. Add the Spring Milestone Repository repository to the pom.xml file
<repositories>
<repository>
<id>spring-maven-milestone</id>
<name>Spring Maven Milestone Repository</name>
<url>http://maven.springframework.org/milestone</url>
</repository><
...
</repositories>
3. Create the TwitterTemplate, and ask for friends
TwitterTemplate twitterTemplate = new TwitterTemplate();
List<String> friends = twitterTemplate.getFriends("chariotsolution");
for (String friend : friends) {
System.out.println("Friend: " + friend);
}
4. Use the code above anywhere in your application
In the next blog, I will cover how to use Open Authentication (OAuth) to perform more Twitter operations.
Simple Spring Social for Twitter Friends
Gordon Dickens recently posted on his blog some thoughts on the Spring Social project.
The Spring Social project provides us developers with an easy way to interact with Twitter, Facebook, LinkedIn & TripIt via the familiar Template objects we have used. Spring has provided Templates for convenient interaction with JDBC, REST, Hibernate, JNDI, and more.
One of the simplest social media calls is to lookup someone’s Twitter friends with the TwitterTemplate.
Read more..
The Spring Social project provides us developers with an easy way to interact with Twitter, Facebook, LinkedIn & TripIt via the familiar Template objects we have used. Spring has provided Templates for convenient interaction with JDBC, REST, Hibernate, JNDI, and more.
One of the simplest social media calls is to lookup someone’s Twitter friends with the TwitterTemplate.
Read more..
Monday, January 10, 2011
An Introduction to Mobile Device Detection
One of our architects, Steve Smith, recently posted this on his blog:
These days, there are many ways to browse the internet. There are desktop browsers, mobile phone browsers, tablets, tablet/phones (e.g. Dell Streak), etc. all with different screen sizes, resolution, and capabilities. How do you render an appropriate view optimized for the device accessing your site? The answer is device detection.
The two main approaches for device detection are server-side detection and client side detection. Server side detection involves determining the device at the time of the request and then presenting the appropriate view. Client side detection involves manipulating the view after the content has been sent to the browser.
Read the full post..
These days, there are many ways to browse the internet. There are desktop browsers, mobile phone browsers, tablets, tablet/phones (e.g. Dell Streak), etc. all with different screen sizes, resolution, and capabilities. How do you render an appropriate view optimized for the device accessing your site? The answer is device detection.
The two main approaches for device detection are server-side detection and client side detection. Server side detection involves determining the device at the time of the request and then presenting the appropriate view. Client side detection involves manipulating the view after the content has been sent to the browser.
Read the full post..
Subscribe to:
Posts (Atom)