473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

understanding buffer overflow

hi-

i am using the abyss webserver at the moment.
i went through the process of how a buffer overflow would work in my mind.
i noticed you can limit the size of post data and its limit value is
displayed on the phpinfo page 8mb. so my question is will the post ever be
so
big that it causes the abyss webserver to have a buffer overflow? if not,
why would you check for length of php input data?

i am trying to review my code for security issues. i found some good
articles. i learned to htmlentities($mydata) before displaying it and
other stuff. i dont feel comfortable about implementing something if
i dont have at least some idea of how it works.

thanks,
jim
Jul 17 '05 #1
5 2420
j-marvin <cu******@service.boy> wrote:
i went through the process of how a buffer overflow would work in my
mind. i noticed you can limit the size of post data and its limit
value is displayed on the phpinfo page 8mb. so my question is will
the post ever be so big that it causes the abyss webserver to have a
buffer overflow?
No program is free from errors, so there is a chance there are
exploitable bufferoverflows in the php/abyss combo. I'm no expert on
overflows, but the size is not the problem. A(ny) maximum is the
problem.
if not, why would you check for length of php input data?
Memory allocation, everything that is posted is mapped to $_POST (or
$_FILES) so it consumes memory, you probably want to limit memory usage
per script execution, limiting post will make sure you have some amount
of memory guaranteed to be available to your script (max. mem- max post).
i am trying to review my code for security issues. i found some good
articles. i learned to htmlentities($mydata) before displaying it


You do escape the quotes here, don't you?

--

Daniel Tryba

Jul 17 '05 #2
Daniel Tryba <ne****************@canopus.nl> wrote in news:ci8u50$aqf$2
@news.tue.nl:
j-marvin <cu******@service.boy> wrote:
i went through the process of how a buffer overflow would work in my
mind. i noticed you can limit the size of post data and its limit
value is displayed on the phpinfo page 8mb. so my question is will
the post ever be so big that it causes the abyss webserver to have a
buffer overflow?
No program is free from errors, so there is a chance there are
exploitable bufferoverflows in the php/abyss combo. I'm no expert on
overflows, but the size is not the problem. A(ny) maximum is the
problem.
if not, why would you check for length of php input data?


Memory allocation, everything that is posted is mapped to $_POST (or
$_FILES) so it consumes memory, you probably want to limit memory

usage per script execution, limiting post will make sure you have some amount of memory guaranteed to be available to your script (max. mem- max post).
i am trying to review my code for security issues. i found some good
articles. i learned to htmlentities($mydata) before displaying it


You do escape the quotes here, don't you?


hi daniel-

so post memory must be like a session variable in that it persists until
the browser closes. that is why i should limit it per script execution
i guess.
when i say this i mean variable post_max_size. each script execution
adds more memory allocated to post.

on the escaping quotes you mean i should escape double quotes...right?
$new = htmlspecialchars("<a href="test">Test</a>", ENT_QUOTES);
# this will produce a syntax error
# Parse error: parse error, unexpected T_STRING in C:\Program FilesAbyss
# Web Server\myfiles\phpinfo.php on line 5
i had only tested it with single quotes (of course).
thanks,
jim

Jul 17 '05 #3
j-marvin <cu******@service.boy> wrote:
so post memory must be like a session variable in that it persists until
the browser closes.
No, it's per http request.
that is why i should limit it per script execution i guess. when i
say this i mean variable post_max_size. each script execution adds
more memory allocated to post.
Let's say, every single request for a php script has a memory limit of
4Mb and a max post size of 3Mb. You not can only allocate another 1Mb in
your script. You might want to make sure you can allocate x Mb but no
more than y Mb... memorylimit would thus be y Mb and maxpost y-x Mb. The
total number of parallel request would only be limited by total memory/y
(neglecting overhead of the httpserver and other processes :).
on the escaping quotes you mean i should escape double quotes...right?
$new = htmlspecialchars("<a href="test">Test</a>", ENT_QUOTES);
# this will produce a syntax error
# Parse error: parse error, unexpected T_STRING in C:\Program FilesAbyss
# Web Server\myfiles\phpinfo.php on line 5
i had only tested it with single quotes (of course).


ENT_QUOTES is what I was hoping for... The syntax error is because:
"foo"bar"foo"
is just plain wrong:
"foo\"bar\"foo"
or
'foo"bar"foo'
or see the manual for heredoc notation.

--

Daniel Tryba

Jul 17 '05 #4
Daniel Tryba <ne****************@canopus.nl> wrote in
news:ci**********@news.tue.nl:
j-marvin <cu******@service.boy> wrote:
so post memory must be like a session variable in that it persists
until the browser closes.


No, it's per http request.
that is why i should limit it per script execution i guess. when i
say this i mean variable post_max_size. each script execution adds
more memory allocated to post.


Let's say, every single request for a php script has a memory limit of
4Mb and a max post size of 3Mb. You not can only allocate another 1Mb
in your script. You might want to make sure you can allocate x Mb but
no more than y Mb... memorylimit would thus be y Mb and maxpost y-x
Mb. The total number of parallel request would only be limited by
total memory/y (neglecting overhead of the httpserver and other
processes :).
on the escaping quotes you mean i should escape double
quotes...right? $new = htmlspecialchars("<a href="test">Test</a>",
ENT_QUOTES); # this will produce a syntax error
# Parse error: parse error, unexpected T_STRING in C:\Program
FilesAbyss # Web Server\myfiles\phpinfo.php on line 5
i had only tested it with single quotes (of course).


ENT_QUOTES is what I was hoping for... The syntax error is because:
"foo"bar"foo"
is just plain wrong:
"foo\"bar\"foo"
or
'foo"bar"foo'
or see the manual for heredoc notation.

i played with the second parameter for htmlentities and i get the same
thing in the url every time. i understand if dont escape double quotes
with a \ i can
get a syntax error.

htmlentities($variable,ENT_QUOTES)
htmlentities($variable,ENT_COMPAT)
htmlentities($variable,ENT_NOQUOTES)

are all the same to me at the moment.
i just dont see how they make a difference.
if someone could post the simplest code they new to explain it that
would be cool. if i had to try and explain it i'd say that
in the url the special characters are all turning to a code like
"confused" looks like http://127.0.0.1:8125/tired.php?tired=%27confused%
27&submit=

and this happens no matter what i use for the second parameter.

thanks daniel.

i need to get some sleep.
i stayed up too late. work ought to be interesting on this little
sleep.

later,
jim


Jul 17 '05 #5
never mind.

i will search google for htmlentities or related functions and
see what people are using for code. i looked at the manual
and so far it hasnt helped yet.

i have lots of time to complete this project anyways.

thanks for helping,
jim
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David Sworder | last post by:
Hi there, I come from a Visual C++ background. When writing a service that's exposed to the Internet, I had to check the incoming data stream (from the client) VERY carefully. If a hacker was...
13
by: Ioannis Vranos | last post by:
If we want our programs to be protected against buffer overflows, must we check the size of the various containers explicitly? E.g. #include <iostream> #include <string> int main()
2
by: Tim::.. | last post by:
Hi... I have a major problem with a web application I am about to launch and just can't find out what the problem is... I believe it might be a Buffer Overflow problem but can't pin point the...
2
by: jay | last post by:
I am attempting to impersonate an account in ASPNET. I am using aspnet_setreg to store the username and passwords. I have given the ASPNET account permisision to read the registry values. However,...
5
by: Tim | last post by:
Hi, I'm experiencing some problem with the following code: st = File.Open(sFilename, FileMode.Open, FileAccess.ReadWrite) br = New BinaryReader(st) Do Until br.PeekChar = -1 Dim buffer()...
2
by: Chris | last post by:
I have experienced the "Blank Message Box" problem when using McAfee 8 with Visual Studio and VB. I can disable buffer overflow protection and it fixes the problem, but it is only temporary as my...
28
by: bwaichu | last post by:
Is it generally better to set-up a buffer (fixed sized array) and read and write to that buffer even if it is larger than what is being written to it? Or is it better to allocate memory and...
9
by: Notebooker | last post by:
Hello, I'm an intermediate noob reading-in data from ascii-file using an ifstream object. I have specified a c-style string buffer with size of type size_t and I am specifying to use this...
4
by: raashid bhatt | last post by:
do buffer overflow happens with global variables
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.