Archive for the ‘Verktyg’ category

Ny TCP-sekvensgenerator för uIP

July 17th, 2010

Tillsammans med Adam Dunkels har jag börjat titta lite försiktigt på att hitta en bättre generator för TCP-sekvensnummer till den miniskula TCP/IP-stacken uIP.

Adam Dunkels
Adam Dunkels – pappa till uIP, bland annat.

Den nuvarande generatorn ger en monotont ökande sekvens som är lätt att prediktera. En ny generator skall ge en bra slumpmässig som inte är lätt (inte går) att prediktera. MEn samtidigt får storleken på stacken inte växa speciellt mycket och skall gå att implementera på en 8-bitars processor. Vidare får vi inte inför en massa nya krav på målsystemet, exempelvis tillgång till bra fysisk entropi. En icke-trivial kombination av krav.

Jag har tänkt, kladdat och sedan postat på Cryptography-listan och fått en del tips. Men jag (vi) tar med stor glädje emot mer klokskap. Här kommer därför min postning till listan. Läs, kommentera. Tack!


uIP [1] is a very compact TCP/IP stack for small, networked connected, embedded devices. (The code size for uIP including TCP and ICMP on the AVR processor is about 5 kBytes.)

Unfortunately, the TCP sequence number generator in uIP is a bit simplistic – basically a monotonically increasing number. In order to reduce the opportunities for TCP Spoofing (like this nice one [2]) we are trying to implement a new TCP sequence number generator.

What we want to find is an algorithm that generates a good (secure) TCP seq numbers, but use very little resources (on 8-bit computing devices).

We have done some preliminary investigations, have some rough ideas and would really appreciate comments and suggestions from the enlightened minds on this list.

As we see it, the two main problems to solve are:
(1) Find a secure PRNG algorithm that have as low implementation complexity as possible.

(2) Add as little system/application requirements on entropy source and persistent storage as possible.

Looking at TinyRNG [3] for example, it seems that a block cipher in CTR mode (or OFB mode) should be sufficient. The question then is what block cipher to use? The XTEA block cipher [4] is very compact, but would it be a wise choice from a security perspective?

But what to feed the PRNG with? Looking again at TinyRNG, it uses a simplistic version of the entropy accumulator from the Fortuna PRNG [5], but with fewer and smaller pools. The pools are processed using a CBC-MAC built around the same block cipher as used in the PRNG.

The combined storage for the pools as well as CBC-MAC state would probably be acceptable for uIP. The question is if the pool feeding operation as such adds operational requirements on uIP that makes it harder to integrate?

A simpler scheme could be to feed the PRNG (CTR-mode) with entropy used as part of Key and IV, that is not use a pool mechanism at all and leave it to user application to provide entropy words when performing a reseed. The Key (and IV?) would also consists of a counter that is monotonically increased.

The problem with this (we guess) is that in order to ensure that KEY+IV is never reused is to keep at least part of KEY or IV as a counter that is stored in persistent memory and increased once (and stored) every time reseed (or boot) is performed. (How bad from a security perspective would this be? Compared to other TCP sequence generators?)

The current version of uIP places few (basically no) demands on the system/application regarding physical resources (besides mem for code and data) and does not use any persistent storage besides code memory. It seems that any good sequence generator that are driven by physical entropy and tries to avoid sequence repetition need to place additional demands on the system. No?

This is basically as far as we have taken this. More or less a bit of Googling, reading and attempts at thinking. The ambition is not to invent something new and unproven but to adapt existing tech and ideas that seem to work. But get it to work with the size, performance and API constraints of uIP.

Any thoughts, comments, suggestions and pointers would be very greatly appreciated.

Thank you!
Joachim Strömbergson

References
—————

[1] A. Dunkels. uIP TCP/IP stack.

http://www.sics.se/~adam/uip/index.php/Main_Page

[1] R. Lawshae. Picking Electronic Locks Using TCP Sequence Prediction
http://www.defcon.org/images/defcon-17/dc-17-presentation/Ricky_Lawshae/defcon-17-ricky_lawshae-picking_electronic_locks-wp.pdf

[3] A. Francillon, C. Castelluccia. TinyRNG: A Cryptographic Random

Number Generator for Wireless Sensors Network Nodes

http://planete.inrialpes.fr/~ccastel/PAPERS/TinyRNG.pdf

[4] R. M. Needham, D. J. Wheeler. Tea extensions.

http://www.cix.co.uk/~klockstone/xtea.pdf

[5] Wikipedia. Fortuna PRNG.

http://en.wikipedia.org/wiki/Fortuna_%28PRNG%29

Länk till Data Compression Explained

June 14th, 2010

Jag insåg att jag gjort bort mig. I postningen om Mahoneys ypperliga genomgång av datakompression, Data Compression Explained glömde jag att ta med länken till just denna sida. Nu är det uppdaterat och för säkerhets skull är den även med i den här postningen. Är du intresserad, nyfiken på datakompression – gå och läs.

Och eftersom jag tog upp Mark Nelsons bok om datakompression – den riktigt klassiska boken på området är Text Compression av Bell, Cleary och WItten. Inte alls lika lättsmält som Nelsons bok eller Mahoneys sida, men väldigt bra.

Ta bort Vuzuvela med mplayer

June 14th, 2010

Fick precis ett tips om att försöka ta bort Vuzuvela-ljudet från fotbolls-VM genom att använda filterfunktioner i mplayer:

mplayer -af
pan=1:0.5:0.5,sinesuppress=233:0.01,sinesuppress=466:0.01,sinesuppress=932:0.01,
sinesuppress=1864:0.01,sinesuppress=232:0.01,sinesuppress=465:0.01,
sinesuppress=931:0.01,sinesuppress=1863:0.01,sinesuppress=234:0.01,
sinesuppress=467:0.01,sinesuppress=933:0.01,sinesuppress=1865:0.01

(Notera “” som markerar att linjen egentligen fortsätter.)

Testa om det funkar. Fotbolls-VM skulle bli mycket mer uthärdligt om det inte var ett konstant bröl.

Nya versioner av libssh2 och openSSL

June 13th, 2010

Det har kommit nya versioner av biblioteken libssh2 och openSSL.

libssh2

Version 1.2.6 av libssh2 inkluderar både en del nya funktioner och ett antal buggfixar, bland annat ett antal fixar av problem som fångats av statisk kodanalys med clang. Mer exakt innehåller den nya versionen följande förändringar:

Changes:

* Added libssh2_sftp_statvfs() and libssh2_sftp_fstatvfs()
* Added libssh2_knownhost_checkp()
* Added libssh2_scp_send64(


Bug fixes:

* wait_socket: make c89 compliant and use two fd_sets for select()
* OpenSSL AES-128-CTR detection
* proper keyboard-interactive user dialog in the sftp.c example
* build procedure for VMS
* fixed libssh2.dsw to use the generated libssh2.dsp
* several Windows-related build fixes
* fail to init SFTP if session isn’t already authenticated
* many tiny fixes that address clang-analyzer warnings
* sftp_open: deal with short channel_write calls
* libssh2_publickey_init: fixed to work better non-blocking
* sftp_close_handle: add precation to not access NULL pointer
* sftp_readdir: simplified and bugfixed
* channel_write: if data has been sent, don’t return EAGAIN

OpenSSL

Den nya versionen av OpenSSL heter 1.0.0a, vilker visar att man iaf än så länge inte övergett sin metod att namnge versioner. Den nya versionen innehåller dock bara en egentlig förändring kopplad till säkerhetsproblemet CVE-2010-1633:

RSA verification recovery in the EVP_PKEY_verify_recover function in OpenSSL 1.x before 1.0.0a, as used by pkeyutl and possibly other applications, returns uninitialized memory upon failure, which might allow context-dependent attackers to bypass intended key requirements or obtain sensitive information via unspecified vectors.

En liten titt på Evernote

June 1st, 2010

Evernote är en väldigt nifty och snygg molntjänst för att hantera anteckningar.

Evernote logo

Med inbyggt stöd för att identifiera text i bilder, snygga till figurer, kopplingar till andra tjänster är det mycket jag gillar med Evernote. Och att döma av kommentarer från de som använder Evernote verkar jag inte vara den enda och att tjänsten faktiskt fungerar. Eftersom det är en molntjänst går det dessutom att komma åt alla sin insamlade information via klienter på mobil, dator, webbläsare etc.

Evernote på iPhone.

Tyvärr måste jag dock, för att citera Tony Irving säga: Men….Kolla in användarvillkoren (Terms of Service) för Evernote:


by using the Service and posting Content, you grant Evernote a license to display, perform and distribute your Content, and to modify and reproduce such Content to enable Evernote to operate and promote the Service. (You also agree that Evernote has the right to elect not to accept, post, store, display, publish or transmit any Content in our sole discretion.)

You agree that these rights and licenses are royalty free, irrevocable and worldwide, and include a right for Evernote to make such Content available to, and pass these rights along to, others with whom Evernote has contractual relationships related to the provision of the Evernote Service, solely for the purpose of providing such services, and to otherwise permit access to your Content to third parties if Evernote determines such access is necessary to comply with its legal obligations.

Jösses, man blir lite tveksam till att använda Evernote – även om det som sagt är en väldigt nifty tjänst.

Statisk kodanalys på libssh2

April 21st, 2010

För några dagar sedan släpptes version 1.2.5 av SSH-biblioteket libssh2.

libssh2-logga.

Eftersom jag använder en Steve Jobs-maskin tänkte jag att det kunde vara kul att testa att bygga libssh2 för att se hur väl det funkar. Det korta svaret visade sig vara alldeles utmärkt. Eftersom libssh2 använder autoconf var det bara att köra ./configure och sedan make och biblioteket byggde utan problem.

MacOSXs utvecklingsmiljö Xcode inkluderar förutom kompilatorn gcc även den LLVM-baserade kompilatorn clang, ett projekt Apple aktivt driver utvecklingen av.

Jag har använt clang och tycker att den är bättre på att hitta problem, ger bättre varningar samt genererar något bättre kod än gcc. Jag testade därför att bygga libssh2 med clang. Genom att helt enkelt deklarera CC=clang som parameter till configure gick det sedan att bygga libssh2. Återigen utan varningar och problem.

En funktion som clang inkluderar är statisk kodanalys. Detta innebär att verktyget går igenom alla logiska vägar i programmet och kan detektera felaktig användning av variabler, ex att variabler blir lästa innan de definierats. Clang utför kodanalysen som en del av kompileringen och genererar sedan ett antal rapporter (webbsidor) som visar de vägar genom koden som leder fram till problem den detekterat. Så här kan en rapport se ut:

kodtrace1.

För att köra kodanalysatorn fristående (i ett terminalfönster) och inte genom Xcode finns det ett litet program kallat scan-build. Installationen av scan-build är så svår som att tanka ner och packa upp katalogen verktyget ligger i. Sedan får man se till att köra configure med CC=scan-build som kompilator och dessutom slå på generering av debuginformation vid kompilering.

Kompilering med scan-build to klart längre än med clang eller gcc, men gick igenom utan problem på libssh2. Resultatet blev att den hittade 67 problem. De flesta av dessa var Dead assignment och relaterade problem, dvs ställen i koden där en variabel uppdateras, men sedan aldrig mer blir läst.

Mer intressant var dock att det upp ett antal logiska fel av typen Dereference of undefined pointer value och Uninitialized argument, dvs ställen där en pekare blir läst som inte blivit definierad samt argument som blir använda men som inte blivit initierade. Dessa problem är mer problematiska och skulle kunna öppna för säkerhetsproblem.

Daniel Stenberg, pappa till libssh2 har nu satt upp ett cronjobb som kör clangs statiska analysator på kodbasen en gång per dygn och genererar rapporter. Här finns exempelvis Rapporterna för för dagens körning (2010-04-21) – och libssh2 är nu nere på 28 problem.

För den som vill se hur scan-build rapporterar olika fel är här en rapport för en död tilldelning och här är en rapport för en derefererad, men icke definierad pekare.

Jag tycker att clang och dess statiska kodanalysator är enkla och smidiga att arbeta med och ger bra återmatning vid kodutveckling. clang är BSD-licensierad och finns till ett flertal plattformar. Håller du på att knacka kod tycker jag att du skall testa clang.

Köp datorspel – sälj din själ

April 18th, 2010

Fox News rapporterar att en brittisk återförsäljare lagt beslag på 7500 kunders själar.

Sälj din själ.

Enligt artikeln hade återförsäljaren GameStation lagt in en klausul i sitt avtal om att kunderna vid köp av ett spel även skrev bort sin juridiska rätt till sin själ. Stycket i avtalet löd:


“By placing an order via this Web site on the first day of the fourth month of the year 2010 Anno Domini, you agree to grant Us a non transferable option to claim, for now and for ever more, your immortal soul. Should We wish to exercise this option, you agree to surrender your immortal soul, and any claim you may have on it, within 5 (five) working days of receiving written notification from gamesation.co.uk or one of its duly authorised minions.”
...
“we reserve the right to serve such notice in 6 (six) foot high letters of fire, however we can accept no liability for any loss or damage caused by such an act. If you a) do not believe you have an immortal soul, b) have already given it to another party, or c) do not wish to grant Us such a license, please click the link below to nullify this sub-clause and proceed with your transaction.”

Avtaltstexten lades in som ett första april-skämt, men GameStation vill även visa på en viktig poäng – folk läser inte avtalen de godkänner. GameStation kommer att skicka ut brev till sina kunder där sektionen i avtalet tas bort.

Det stora bekymret med den här typen av avtal är att det är så långa och krångliga att det som vanlig dödlig, icke-jurist knappast klarar av att läsa och begripa implikationerna (även om man nog fattat GameStations avtalstext). När Apple uppdaterade avtalet för iTunes för iPhone fick jag upp ett dokument på telefonen på 75(!) sidor att läsa igenom. I stort sett en DoS-attack på sina kunder att skicka ut en sådan text. Även Facebook, Google m.fl. har fått kritik för sina långa avtal.

I sammanhanget tycker jag att det arbete Alan Siegel gjort och som han presenterade på TED är helt rätt:

Qubes – Ett nytt operativsystem

April 11th, 2010

Joanna Rutkowska, känd för sin forskning om säkerhet och virtualisering (exempelvis Blue Pill) har utvecklat ett nytt operativsystem.

Joanna Rutkowska.

Det nya OSet kallas Qubes är baserat på den öppna hypervisorn Xen och målet är att genom att isolera applikationer från varandra skapa ett säkert OS för desktop-maskiner.

Qubes logga.

Förutom Xen använder/bygger Qubes på Linux och ser i stort sett ut som vilken modern Linux som helst. Här är en skärmbild:

Flera apps från olika VMs
Flera olika applikationer från olika virtuella maskiner.

En viktig fråga när det kommer till isolering (sanboxing) är hur delning av data skall ske. Qubes inkluderar funktioner för att säkert klipp & klistra mellan applikationer i olika maskiner och vem som har access till klibb-bufferten. Qubes har även stöd för att kopiera filer/data mellan olika virtuella maskiner.

Att köra ett flertal (stort antal) virtuella maskiner skulle man kunna tro vore prestandakrävande, men följande bild sägs visa att maskinerna tar väldigt lite resurser när de inte arbetar:

TOP.

Qubes går just nu bara att installera på 64-bitprocessorer och inte att köra i en virtualiserare (den behöver access till den fysiska maskinen.)

Arkitekturen finns kortfattat beskriven på webben. Följande figur visar hur OSet skapar olika virtuella maskiner för varje applikation som körs av Xen.

Arkitektur.

Rutkowska & Co beskriver hur det fungerar så här:

Qubes implements Security by Isolation approach. To do this, Qubes utilizes virtualization technology, to be able to isolate various programs from each other, and even sandbox many system-level components, like networking or storage subsystem, so that their compromise don’t affect the integrity of the rest of the system.

Qubes lets the user define many security domains implemented as lightweight Virtual Machines (VMs), or “AppVMs”. E.g. user can have “personal”, “work”, “shopping”, “bank”, and “random” AppVMs and can use the applications from within those VMs just like if they were executing on the local machine, but at the same time they are well isolated from each other. Qubes supports secure copy-and-paste and file sharing between the AppVMs, of course.

Arkitekturen är även närmare beskriven i ett dokument (PDF). Det finns en PDF att läsa för den som vill veta mer och det finns även en Qubes-Trac med Wiki. (Bra projekt kör Trac.)

OpelSSL når 1.0.0

March 30th, 2010

OpenSSL, Open Source-biblioteket som implementerar Secure Sockets Layer (SSL v2/v3) och Transport Layer Security (TLS v1) släpptes igår (2010-03-29) i version 1.0.0.

OpenSSL

Den nya releasen innehåller ett flertal fixar och nyheter (ChangeLog), men varför man valde att gå till 1.0.0 nu är inte helt klart. OpenSSL som projekt startade i december 1998 och första versionen var 0.9.1c(!). Sedan dess har man under nästan tolv års tid harvat med 0.9.x-inkrement.

Psykologiskt är det dock viktigt att det nu finns en 1.x-version av OpenSSL – för en utomstående kan det vara svårt att tro att något med version 0.9.8n är stabilt och lämpligt att använda i seriösa tilämpningar. Tittar man längst upp i ChangeLog ser det ut som att nästa version kommer att heta 1.1.0 så dom verkar gå mot mer normala versionsnummer.

För den som vill tanka ner version 1.0.0 av OpenSSL finns den här.

Uppdaterad 2010-03-31:
Hittade en pressrelease från OpenSSL som beskriver 1.0.0-releasen:


The OpenSSL project team is pleased to announce the release of version 1.0.0 of our open source toolkit for SSL/TLS. This new OpenSSL version is a major release and incorporates many new features as well as major fixes compared to 0.9.8n. For a complete list of changes, please see http://www.openssl.org/source/exp/CHANGES .

The most significant changes are:

o RFC3280 path validation: sufficient to process PKITS tests.
o Integrated support for PVK files and keyblobs.
o Change default private key format to PKCS#8.
o CMS support: able to process all examples in RFC4134
o Streaming ASN1 encode support for PKCS#7 and CMS.
o Multiple signer and signer add support for PKCS#7 and CMS.
o ASN1 printing support.
o Whirlpool hash algorithm added.
o RFC3161 time stamp support.
o New generalised public key API supporting ENGINE based algorithms.
o New generalised public key API utilities.
o New ENGINE supporting GOST algorithms.
o SSL/TLS GOST ciphersuite support.
o PKCS#7 and CMS GOST support.
o RFC4279 PSK ciphersuite support.
o Supported points format extension for ECC ciphersuites.
o ecdsa-with-SHA224/256/384/512 signature types.
o dsa-with-SHA224 and dsa-with-SHA256 signature types.
o Opaque PRF Input TLS extension support.
o Updated time routines to avoid OS limitations.


We consider OpenSSL 1.0.0 to be the best version of OpenSSL available and we strongly recommend that users of older versions upgrade as soon as possible.

GPU-accelererad lösenordsknäckare

March 27th, 2010

Elcomsoft har släppt lösenordsknäckare som är accelererade prestandamässigt med grafikprocessorer (GPU).

Elcomsoft

De nya lösenordsknäckarna attackerar lösenord för Wi-Fi lösenord (WPA-PSK) samt lösenordsskyddade backuper från iPhone och iPod. Elcomsoft använder ATI Radeon 5000-GPU:er.

ATI Radeon 5000

Benchmarkmätningar visar enligt ElcomSoft att ATI Radeon HD5970 ger 20x högre prestanda för lösenordsknäckning än Intels Core i7-960. Elmcomsoft ser även att dom får mycket bättre prestanda än med Nvidias Tesla-kort:

WPA-PSK-prestanda.