Blog:tech
This is a simple tech blog. I am mostly interested in application security, web, technologies... but every time I can, I try to play with some other field I like such as data-mining, graph theory, compilers, languages, etc..Contact:
It's so sad. As a web developer (sometimes), I used to do CSS and like almost all CSS developers you will have some trouble. A bad but fast solution I used to do is to duplicate CSS statement for IE, like this one:
body {
background-color: green; /* Green for everybody */
_background-color: red; /* Overload to red for Internet Explorer */
}
But this trick is not working anymore with IE7, it doesn't understand the underscore... the solution? Add a point!
body {
background-color: green; /* Green for everybody */
_background-color: red; /* Overload to red for Internet Explorer 6 */
.background-color: blue; /* Overload to blue for Internet Explorer 7 */
}
This is really sad! First of all, the old hack is well none and used... so, lots of CSS are actually not working like it should do with IE7. Why the heck they did that? Isn't Microsoft good are retro-compatibility? Thought so....
Since yesterday, I'm working on a data-flow problem. I need to model a function and I should do all the data-flow process. Well, that's kinda long if I have to do that on all functions and especially I will never use much of the information I would generate by analyzing the tree associated to the function (local variables etc.). So what the point of doing that? None.
I was stuck at this point, didn't find a good way to model a function (entry parameters, global calls etc.) so I thought of reasoning as a crystal ball. I can see what it is, but it's kinda blurry :) I am now modeling a function as inputs and outputs, only in terms of functions and global variables interaction. By this, I should be able to see the possible interaction of the given function on the system. Hope it's gonna work well!
Romain | Tuesday, October 16 2007 - 10:26 UTC | Information
I'm not usually posting news about article, blog entries etc. But this one is actually a very good one. Michael Howard is actually sharing his 5 years experience about secure code.
Here is the article: http://msdn.microsoft.com/msdnmag/issues/07/11/Lessons/
Romain | Wednesday, October 10 2007 - 18:31 UTC | Discussion
I'm not gonna write a long entry about Security Metrics, but since I've been working on this for a couple of weeks now, I have some thoughts. Evaluating the security of a source code is actually pretty hard. Even if I'm sure there is a lot of source code security metrics out there, it's often (I guess) hard to compute. Basically, you will need to know lots of things about the source code then, you need an engine working on the AST , data-flow etc.
This is what I've done for a couple of months, an engine which is working on XML AST, generated by yaxx (this is the same engine that I use to do source code modifications, obfuscations, etc.).
With Vadim Okun, we had the idea of computing the "size" of the security in a source code. The idea is pretty simple and we are aware that this is limited to implementation flaws and not design flaws for now. The "size" of the security is the number of inputs going to sinks.
The inputs have to be taken in the large sense, these are in fact all the variable that are derivate from direct inputs. Here is a simple example of the variable diffusion:
$a = $_GET['foo']; $b = htmlentities($a); echo $b;
We are here counting $a and $b since $b is a modification of $a which is a direct input. We are using the same methodologies for all possible modification (concatenation, cast, etc.).
Once we know these variables, we are counting the ones that are going to sinks. The sinks are a list of function such as 'echo', 'mysql_query', 'fopen', and so on. Our list of sinks is directly coming from the PHP-SAT project. In the previous example, the metric result is 1 since there is only one sink 'echo' where a derivate input is going to.
And here we are, this is a fairly simple (in the idea, not the implementation) way to evaluate the possible security problems that you can have in your source code. We are going to try and evaluate this metric on different open source project (wordpress, joomla, mediawiki etc.). I'm sure this is really incomplete: first because we are only counting the security problems that are coming from inputs but also because it really depends on the programmer (his style of programming).
An other example is available here: smetric.pdf
For the revised version, the first add would be to count the output validation problems. But for that purpose, I need a stronger data-flow analysis which would analyze in function definitions (not done yet). Then, I will be able to trace everything coming from supposed secure sources (databases, resources, local files, etc.) to sinks. Maybe the weight of such flows would be different than the first one (input to sink)...
I really think it's a good thing do open the XSS scanning like this, definitely a good point Acunetix. What I don't really like though is the commercial points here. They are actually releasing the demo version with XSS scanning free for all websites (all other scanning are then limited to their test websites - which you shouldn't care about for any vendors).
Anyway, good point Acunetix! I wish lots of commercial will release some free tools or even their own little tools (SPI has a lot of good ones!)
Romain | Tuesday, September 4 2007 - 16:31 UTC | Vulnerabilities
Source Code Obfuscation is actually a powerful tool for testers. Whether you use it to obfuscate your bytecode (Java, .NET etc.) or increasing the code complexity of your current source code.
Working at SAMATE we are also playing, tweaking, testing, stressing source code analyzers. And now you see the relation. I'm writing a source code obfuscater in order to increase the complexity of our test cases and see if the tools are still doing well.
Thus, I was able (with good documentation, and yaxx) to create one. It currently only add control flow complexity (and of course renaming classes, functions and variables).
You may have heard about obfuscation in a sense of making the code unreadable for users. This is not what I'm interested in. I want to modify the actually source code, adding some information in it, some tests... I need the outputs of the original program and the obfuscated one to be the same, otherwise we cannot consider the source code as being equivalent.
So for example if I do:
if (var == 0) {
echo 0;
}
I will have the same behavior with this source code:
x = some_value;
if (var == 0 or x*x < 0) {
echo 0;
}
Even though they have the same output, the second one is more complicated since it adds one other test.
To see what it exactly does given this original source code
<?php
$b = 0;
$c = "Salut";
$len = strlen($c);
function fct($a) {
return $a . "_1\n";
}
class T {
function foo() {
echo "test\n";
}
}
echo fct(0);
echo T::foo();
?>
...and by choosing one of my control flow obfuscating pattern
<?php
class rand_class_name {
function rand_func_name_2($rand_name_1) {
return $rand_name_1 + 1;
}
}
function rand_func_name_1($rand_name_2) {
return $rand_name_2 + 1;
}
if (rand_func_name_1(0) > 0 && rand_class_name::rand_func_name_2(0)) {
$enter_the_new_statement;
}
?>
To have this result:
<?php
function HXvE5Plwxp0RSoQM ( $ZMfP98Az96Rq67j6 ) {
return $ZMfP98Az96Rq67j6 + 1 ;
}
class TF03COvMuzXRQcCK {
function Ltghf3a0McCI8RaZ ( $V309os5vQo15ak9b ) {
return $V309os5vQo15ak9b + 1 ;
}
}
$b = 0 ;
$c = "Salut" ;
$len = strlen ( $c ) ;
function fct ( $a ) {
return $a . "_1\n" ;
}
class T {
function foo ( ) {
echo "test\n" ;
}
}
if ( HXvE5Plwxp0RSoQM ( 0 ) > 0 && TF03COvMuzXRQcCK :: Ltghf3a0McCI8RaZ ( 0 ) ) {
echo fct ( 0 ) ;
}
if ( HXvE5Plwxp0RSoQM ( 0 ) > 0 && TF03COvMuzXRQcCK :: Ltghf3a0McCI8RaZ ( 0 ) ) {
echo T :: foo ( ) ;
}
?>
First of all, the engine only works on Abstract Syntax Tree (AST) in order to do powerful manipulation and code refactoring. The idea is to take a couple of transformation patterns (the second source code is in fact a complicated one), and fitting this patterns with the original source code.
The patterns are meta code. You can see that they are in PHP using some names such as $rand_name_1 etc. this means that the engine will generate one unique name for each of them and replace it before the actual refactoring.
Select what I want to obfuscate is not a real problem, but for now I only selected the top statements and will apply the whole modifications to each of them.
A little schema explaining a little how it works is available here: schema_obfuscation.png
The applied control flow obfuscating pattern is on of the many I do have for now (many more to come), and I guess this is kinda promising, lots of interesting studies should come now.
Currently the tools is only for PHP but I should make it general by using my own AST nodes names and then be able to do code transformation on C, C++, Java etc.
There is no release of the tool (written in C++) right now, I will wait until it's more than correct and clean. I also need to do data obfuscation (using indirections etc.). The program will of course be public and free for everybody when it's gonna be ready.
Okay, I know for the halting problem etc. Some theoretical stuff... But now that I'm working on one, I have to say:
Damn! That so complicated to do a source code scanner!
The dataflow is a real pain in the ass, and we know that it's impossible to have a real and full dataflow. But well, we need to do some. The dataflow is more complicated theoretically but what about the control flow? No really easier! I mean... that's easier but there are so many things to understand, so many patterns to recognize in order to build the model of the source code... And I'm not even talking about inter procedural stuff, multi-file source code etc.
So, I'd like to apologize to "I don't remember who are these people" but some source code scanners are good :) Well... for the moment! I'm really waiting for to see more high-tech stuff and AI in these kind of programs...
Anyway, I'm currently building a core engine working on a AST tree generated by yaxx (XML version). I have two short terms targets:
Romain | Thursday, August 23 2007 - 15:36 UTC | Information
Here is a new interesting project: WASSEC. This WASC's project is run by Anurag Agarwal and is about the evaluation of web application scanners such as Watchfire's AppScan, SPI's WebInspect etc.
If you are in the field, don't wait to help us :). Here is Anurag's words:
Thank you all for your patience. We have received an overwhelming response from the WASSEC (Web Application Security Scanner Evaluation Criteria) project. To proceed with the project please
1. Please email wasc-wassec-subscribe(AT)webappsec(DOT)org and reply to confirmation email.
2. It is moderated subscription so every contributor has to be approved to send messages to the list.
3. Once you are subscribed to the list, then email wasc-wassec(AT)webappsec(DOT)org to post messages.
All further communication will be done through the mailing list. Please keep checking your junk mail folder in case some messages might go there. We are also in the process of setting up a wiki for the length of the project to post updates, etc. Until then I will be updating my blog with the project details.
Once again, thank you for your participation.
You can checkout the project here: http://webappsec.org/projects/wassec
Romain | Wednesday, August 15 2007 - 13:18 UTC | Information
Thanks to ExtendeD, I've fixed the comment issues on the website. It's now possible to post again... Sorry for the problems.
Romain | Wednesday, August 8 2007 - 18:37 UTC | Vulnerabilities
Protecting against Cross-Site Request Forgery
(CSRF) is something that we tend to see everywhere now.
What we usually see is a solution with a token in the form pdp described this a couple of months ago here: Preventing CSRF. Now, the problem is when you don't have dynamic pages, when you are stuck with static HTML pages but you can use JavaScript! Of course, the first reflex when you want to prevent CSRF is to use only POST variable when you send data, this make the attack a little harder.
I started thinking of this because I had this problem: I had static pages that are using Ajax to send data using POST. I talked with Stefano Di Paola about this (because my problem was not only CSRF, but also parameter tampering...). We both conclude on the following Ajax based solution:
So you need 3 files:
You can find the demo here: anti-csrf/index.html
wwwCall is a very small module for Python (tested under python 2.5 but should be okay for python >= 2.3) which handle the HTTP(S) connection with some special features like proxy, cookies, authentification (basic, digest). This morning, I was working on Grabber and I just realized how ugly the code was, mostly because of how I handled the web connections, so I decided to create a simple module to do the job easily. The idea is to have a single object handling some basic function of the python urllib2.
If you have ever use Python for doing web calls, you'll see that the utilization is damn simple and I think, pretty cool... Example:
# create the object
http = wwwCall('http://rgaucher.info')
# add the features you want (cookies,auth)
http.setCookieFile('./the_path/file.cookie')
# reaching a logging URL and saving the cookie
http.post("http://rgaucher.info/login.php",{'username' : 'foo', 'password' : 'bar'})
# register the username/password for the basic authentification
http.setAuthBasic("romain","mypassword")
# print the content of the protected page
print http.get("http://rgaucher.info/401protected").read()
Download: wwwCall.zip
So, I've been working on Grabber for a couple of months without a release now; it's mainly because I don't have that much time to work on it, but also because I made lots of modification. Today I added a couple of features:
This comes in addition on the previous features I added, mainly:
I cannot give a d-day for the release of the 0.2 version because I really want to have a more stable product and will feed some test suites I made at work the tool, to be sure it's reasonable (I will not give comparison results with commercial products :P). I also want to have a better spider...
Romain | Thursday, July 12 2007 - 14:12 UTC | Information
Coverage is a tool written in Python which allows you to track what functionalities/web pages are reached on your website. I use this tool for in my Web Apps Scanner evaluation methodology in order to know if the web apps scanner was able to scan every pages, every functionalities of my test apps.
Anyway, this tool is pretty easy to use even if it requires a MySQL database to store the EntryPoints of the application. Basically, you setup the database, you insert the entry points into your code and you run the python script which will generate an HTML report with SVG graphs, reporting the coverage of your application.
Here is a report example
The database design I used for storing the needed information is the following:
CREATE TABLE `coverage` ( `CoverageID` int(32) NOT NULL auto_increment, `Apps` varchar(128) character set utf8 collate utf8_unicode_ci NOT NULL, `Date` date NOT NULL, `EntryPoint` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL, `Origin` varchar(255) character set utf8 collate utf8_unicode_ci NOT NULL, PRIMARY KEY (`CoverageID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
** File Reached:
Touch_ + Name of the file with extension, example, Touch_Index.Php, Touch_Search.Php etc.
** Functionality Reached:
Name of the functionality + _ + Name of the file with extension, example, this sequence of entry points of
the page Login.php of a given application:
<?php
// ...
$origin = md5($_SERVER['HTTP_USER_AGENT']). '|' . date("j-m-y H:i");
?>
So, you will need to add, in your apps code, lots of entry points. I made a PHP source code to do that more easily:
<?php
class Coverage{
private $coverage_id = false;
private $coverage = null;
function __construct() {
$this->coverage_id = true;
$this->coverage = mysql_connect('192.168.1.3:3306', 'test', 'test');
mysql_select_db("test_collect");
}
function send($entryPoint){
if ($this->coverage) {
$origin = "";
$origin .= md5($_SERVER['HTTP_USER_AGENT']);
$origin .= ('|' . date("j-m-y H:i"));
$entryPoint = mysql_real_escape_string($entryPoint);
mysql_query("INSERT INTO coverage VALUES(NULL,'BankApp',NOW(),'$entryPoint','$origin')");
}
}
};
$coverage = new Coverage();
function register_EntryPoint($entryPoint) {
global $coverage, $supportCodeCoverage;
if ($supportCodeCoverage) {
$coverage->send($entryPoint);
}
}
?>
Insert this code in a header or something and call:
register_EntryPoint('Touch_MyFile.Php');
etc. in your code where you have functional difference.
To run the tool, you need to have:
example:
$ python coverage.py 2007-06-28 41942da0293d0b8afcfab4c2d10c2401 $ python coverage.py 2007-04-12
The script must be in the same directory of your files for now... you can download the archive here: coverage.zip
Romain | Wednesday, June 27 2007 - 15:53 UTC | Information
This is a really nice initiative from Christian and Ronald: http://planet-websecurity.org/
This is for now an aggregator for a couple of web security websites (really good ones).
This site will replace 7 rss I already have :)
Thanks guys
Make sure that your test case is correct!!!!!
Damn I'm stupid, I was working on Grabber on the session state management, and of course, I did a small test case with a couple of pages to be sure the spider can reach every pages. But, my test case was just stupid and calling twice my index make my session still alive, but the variables were set to an order just crazy and have the same effect as destroying the session.
Anyway, now it works! At least in the next Grabber release:
I don't know yet when I'm gonna release the version, I need to make sure it works correctly and is stable, I also need to create something to generate nice report (maybe simple XSLT sheets developer/user side) and I want to work more on the hybrid mechanism using different tools (fortify,pixy,php-sat,swaat...)
I already talked about source code scanners for PHP, and even run a simple test between SWAAT and PHP-SAT. Today, a new toy has been released: Pixy, so I decided to make it pass the test. The first test is really basic, having a quite small php source code with a bunch of possible faults: tests.php
So, you find the output of the tool here: out.pixy.result.txt
I first have to say that it's normal that the tool doesn't catch the header injection stuff, os command injection etc. it doesn't claim to do that. Pixy claims to find the Cross-Site Scripting and the SQL Injection. On that point, I would say pretty good job guy!
The tool catch all the possible Cross-Site Scripting in the echo functions, doesn't warn for the persistent XSS (line 34, the bad html injection would be inserted into the SQL database, if there is no output validation, there are Persistent XSS).
Even better on the SQL Injection where it found every thing I tagged as true-positive.
To conclude, I will definitely keep an eye on this tool which looks promising to me, I will also continue working on the PHP-SAT security configuration in order to make a solid vulnerability disclosure system.
Romain | Monday, June 18 2007 - 22:35 UTC | Information
After Watchfire acquired by IBM, it seems like HP would be close to SPI-Dynamics!
So, it will be likely IBM vs. HP vs. Cenzic vs. Acunetix... But Cenzic doesn't care, they have the "Fault Injection" patent ^^
Romain | Monday, June 18 2007 - 19:14 UTC | Information
Google has just released the so called "Safe Browser API" which allows everybody to know if a given url is known as a phishing website or malwares infested page. This service is already working with Firefox.
Romain | Sunday, June 17 2007 - 20:08 UTC | Discussion
As most of expatriate, I'm aware of what are the news in my country (France) by watching news websites, mostly, I'm watching France 24 which claims to be the French CNN... Anyway, I was watching some videos, and at the end, like on some websites I'm going (depending on if I have time etc.) I looked at how it works, if it has vulnerabilities etc.
Of course, it has some, I will not tell here because I didn't tell them yet, but you can find on the most easy way XSS. What's different with other websites? Nothing but they give information, so people trust them.
There are several types of websites, but I could say that their behavior fits in 3 different categories:
While XSS'ing that website, I thought that it could have a huge impact to be able to change information (we could have seen that with the story of Apple and the wrong news on eGadget...) . Of course, everybody reading this blog is aware of this, but I'm pretty sure that most of other people just think that vulnerabilities are used to get information, not to store.
So, nothing much here, just thought about how a simple SQL Injection, Permanent XSS, File Inclusion or even information/credentials disclosure could have a huge impact on the World :/
On that conclusion, I could say that the information websites and others security/integrity, as christian1 said month ago, belongs to theses companies! They must understand that without a real strict management of their security, their information could be stolen, replaced by bad people and they must be responsible of that since they are making lot of money on that...
Romain | Wednesday, June 6 2007 - 11:20 UTC | Information
And they plan to buy it: read the news here
« previous entries - page 3 of 7 - next entries »
Last comments