security - Vulnerability in the functional programming paradigm? -


A few days ago, there were some questions on buffer overflow weaknesses (such as, to name a few), which can do. This is what happens in the compulsory programming languages.

Functional Programming (I'm trying very hard), I can see that will not occur due to weaknesses such as buffer Ovrflu because they have problems of a change to a field on the status of a program or memory the results (please correct me if I'm wrong.)

compiler, without accounting for the possibility of the weaknesses in interpretation or execution environment are there any types Are security vulnerabilities that are present in functional programming paradigm? Are there any specific types of weaknesses that exist in functional programming but not mandatory programming?

If you do not expect a programmer that [input] [program] may be, it is a vulnerability as possible, DoS I have seen all the turing-the entire language is weakness, but the dullness of Haskell is hard to understand as to how a calculation is involved.

For example (but simulated) example,

  import control.Monad (when) Import System (GetArgs) main = do file & lt; - getArgs content & lt; - mapM readFile files flip mapM_ (ZIP files content) $ \ (file, content) - & gt; When empty (empty content) $ putStrLn $ file ++ is "empty"  

The naive programmer might think, "Haskell is lazy, so it will not open until it is needed" And "Hashkel is collected in garbage, so once it is done with the file, this file can handle the handle". Unfortunately, this program will actually open a lot of files at once (implementation-specific), and only empty files will close their file handle (side effects of implementation rules):

 $ ghc - - Make-O2 Test [1 1] compiling Maine (Test. HS Test. o) adding testing ... $ stretch -set = open, close ./Test dir / * / dev / null. .. open ("DIR / 1", O_RDNC | ONCTTI | O_ONBLOCK | O_LARGEFILE) = 3 open ( "Dior / 2", O_Rodony | O_NCTTI | O_Nblock | O_LARGEFILE) = 4 open ("DIREES / 3", O_RDNLI | ONCTTY | O_ONBLOCK | O_LARGEFILE) = 5 open ("GR / 4", O_ORONY | O_NOCTTY | O_NONBLOCK | O_LARGEFILE) 6 = open ( "Dyer / 5", O_ardiansi | O_ansititiai | O_anonblok | O_LARGEFILE) = 7 ... open ( "/ dev / null", O_rdoni | O_NOCTTY | O_NONBLOCK | O_LARGEFILE) = 255 Close (255) / dev / Null is empty $ 

Maybe you do not expect the occasional "too many open files" error -EMFILE.

Like I said, this is a responsive example, and can be done in other languages ​​too, but some cooks are easy to remember. RCE usage in Haskell


Comments