Programmer's Ultimate Security DeskRef

_ftprintf

Prototype: int _ftprintf( FILE *stream, const _tchar *format [, argument ]...)

Summary: This function prints a string to a file stream.

Description: This function attempts to print a string to a filestream. It has two format input arguments. The first is the filestream to be written to, while the second is the t-character string to write. Informally, the function may have more arguments, as the string could have its own arguments due to formatting. The function returns the number of characters written to the stream. In the event of an error, the function returns a negative value.

Risk: This function is potentially vulnerable to a format string attack where an attacker could cause the application to crash unexpected or execute arbitrary code. Format string bugs were discovered in 2000 and the problem is typically spawned from user input that is not properly filtered. Both Microsoft .Net and SPI Dynamics to name two have secure objects that can be implemented to check strings and user input gained from human sources within applications to protect against input-directed vulnerabilities. It is critical that you verify the inputted data have only proper and expected characters in addition to ensuring that your function is properly called. For example, the functions should always utilize their parameters such as printf("%s", malicious_string) instead of printf(malicious_string).

Note: At time of publication, this function was designed for Windows compatibility.

Additional Resources: www.gnu.org/software/libc/manual/html_node/Formatted-Output-Functions.html#Formatted%20Output%20Functions; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt_fprintf.2c_.fwprintf.asp

Impact: Medium

Cross References: _cprintf, fscanf, sprintf

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Barcode Decoders
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.