skip to main content
10.1145/940071.940113acmconferencesArticle/Chapter ViewAbstractPublication PagesfseConference Proceedingsconference-collections
Article

Protecting C programs from attacks via invalid pointer dereferences

Published:01 September 2003Publication History

ABSTRACT

Writes via unchecked pointer dereferences rank high among vulnerabilities most often exploited by malicious code. The most common attacks use an unchecked string copy to cause a buffer overrun, thereby overwriting the return address in the function's activation record. Then, when the function "returns", control is actually transferred to the attacker's code. Other attacks may overwrite function pointers, setjmp buffers, system-call arguments, or simply corrupt data to cause a denial of service.A number of techniques have been proposed to address such attacks. Some are limited to protecting the return address only; others are more general, but have undesirable properties such as having a high runtime overhead, requiring manual changes to the source code, or forcing programmers to give up control of data representations and memory management.This paper describes the design and implementation of a security tool for C programs that addresses all these issues: it has a low runtime overhead, does not require source code modification by the programmer, does not report false positives, and provides protection against a wide range of attacks via bad pointer dereferences, including but not limited to buffer overruns and attempts to access previously freed memory. The tool uses static analysis to identify potentially dangerous pointer dereferences, and memory locations that are legitimate targets of these pointers. Dynamic checks are then inserted; if at runtime the target of an unsafe dereference is not in the legitimate set, a potential security violation is reported, and the program is halted.

References

  1. L. O. Andersen. Program Analysis and Specialization for the C Programming Language. Ph.D. thesis, DIKU, University of Copenhagen, May 1994. (DIKU report 94/19).]]Google ScholarGoogle Scholar
  2. K. Ashcraft and D. Engler. Using programmer-written compiler extensions to catch security holes. In IEEE Symposium on Security and Privacy, May 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. T. Austin, S. Breach, and G. Sohi. Efficient detection of all pointer and array access errors. In ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 290--201, Orlando, FL, June 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. T. Ball and S. Rajamani. The SLAM toolkit. In 13th Conf. on Computer Aided Verification, pp. 260--264, July 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. R. Bodik, R. Gupta, and V. Sarkar. ABCD: Eliminating array bounds checks on demand. In ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 321--333, Vancouver, BC, June 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. W. Bush, J. Pincus, and D. Sielaff. A static analyazer for finding dynamic programming errors. Software--Practice and Experience, 30(7):775--802, June 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. cfingerd: Configurable finger daemon. http://www.infodrom.org/projects/cfingerd/]]Google ScholarGoogle Scholar
  8. Ckit. http://www.smlnj.org/doc/ckit/]]Google ScholarGoogle Scholar
  9. J. Condit, M. Harren, S. McPeak, G. Necula, and W. Weimer. CCured in the real world. In ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 232--244, San Diego, CA, June 2003.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C. Cowan, C. Pu, D. Maier, H. Hinton, P. Bakke, S. Beattie, A. Grier, P. Wagle, and Q. Zhang. Automatic detection and prevention of buffer-overflow attacks. In 7th USENIX Security Symposium, San Antonio, TX, Jan. 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Das. Unification-based pointer analysis with directional assignments. In ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 35--46, Vancouver, BC, June 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. D. L. Detlefs, K. R. M. Leino, G. Nelson, and J. B. Saxe. Extended static checking. Tech. Report SRC-159, Compaq SRC, 1998.]]Google ScholarGoogle Scholar
  13. N. Dor, M. Rodeh, and M. Sagiv. Cleanness checking of string manipulations in C programs via integer analysis. In The 8th International Static Analysis Symposium, volume 2126 of Lecture Notes in Computer Science, page 194. Springer, July 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. D. Evans. Static detection of dynamic memory errors. In ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 44--53, Philadelphia, PA, May 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. R. Gupta. Optimizing array bound checks using flow analysis. ACM Letters on Programming Languages and Systems, 2(1--4):135--150, Mar.--Dec. 1993.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. R. Hasting and B. Joyce. Purify: Fast detection of memory leaks and access errors. In Proceedings of the Winter Usenix Conference, 1992.]]Google ScholarGoogle Scholar
  17. T. Jim, G. Morrisett, D. Grossman, M. Hicks, J. Cheney, and Y. Wang. Cyclone: A safe dialect of C. In USENIX Annual Technical Conference, Monterey, CA, June 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. P. Kolte and M. Wolfe. Elimination of redundant array subscript range checks. In ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 270--278, La Jolla, CA, June 1995.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. W. Landi and B. Ryder. A safe approximate algorithm for interprocedural pointer aliasing. In ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 235--248, San Francisco, CA, June 1992.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. A. Loginov, S. Yong, S. Horwitz, and T. Reps. Debugging via run-time type checking. In Fundamental Approaches to Software Engineering, volume 2029 of Lecture Notes in Computer Science, pp. 217--232. Springer, Apr. 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. M. Lujan, J. R. Gurd, T. L. Freeman, and J. Miguel. Elimination of java array bounds checks in the presence of indirection. Tech. Report CSPP-13, Department of Computer Science, University of Manchester, Feb. 2002.]]Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. V. Markstein, J. Cocke, and P. Markstein. Optimization of range checking. In ACM SIGPLAN Symposium on Compiler Construction, SIGPLAN Notices 17(6), pp. 114--119, Boston, MA, June 1982.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. G. Necula, S. McPeak, and W. Weimer. CCured: Type-safe retrofitting of legacy code. In ACM Symp. on Principles of Programming Languages, Portland, OR, Jan. 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Openwall project linux kernel patches. http://www.openwall.com/]]Google ScholarGoogle Scholar
  25. Packet storm. http://packetstormsecurity.org/]]Google ScholarGoogle Scholar
  26. Parasoft. Insure++: An automatic runtime error detection tool. http://www.parasoft.com/insure/]]Google ScholarGoogle Scholar
  27. H. Patil and C. Fischer. Low-cost, concurrent checking of pointer and array accesses in C programs. Software--Practice and Experience, 27(1):87--110, Jan. 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. J. Seward. The design and implementation of Valgrind. http://developer.kde.org/~sewardj/]]Google ScholarGoogle Scholar
  29. N. P. Smith. Stack smashing vulnerabilities in the UNIX operating system. Technical report, Computer Science Department, Southern Connecticut State University, 1997.]]Google ScholarGoogle Scholar
  30. Immunix Stack Guard. http://immunix.org/stackguard.html]]Google ScholarGoogle Scholar
  31. Stack Shield. http://www.angelfire.com/sk/stackshield/]]Google ScholarGoogle Scholar
  32. N. Suzuki and K. Ishihata. Implementation of an array bound checker. In ACM Symp. on Principles of Programming Languages, pp. 132--143, Los Angeles, CA, Jan. 1977.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. D. Wagner, J. Foster, E. Brewer, and A. Aiken. A first step towards automated detection of buffer overrun vulnerabilities. In Symp. on Network and Distributed Systems Security, pp. 3--17, San Diego, CA, Feb. 2000.]]Google ScholarGoogle Scholar
  34. R. Wilson and M. Lam. Efficient context-sensitive pointer analysis for c programs. In ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 1--12, La Jolla, CA, June 1995.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. S. Yong, S. Horwitz, and T. Reps. Pointer analysis for programs with structures and casting. In ACM SIGPLAN Conf. on Programming Language Design and Implementation, pp. 91--103, Atlanta, GA, May 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Protecting C programs from attacks via invalid pointer dereferences

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in
          • Published in

            cover image ACM Conferences
            ESEC/FSE-11: Proceedings of the 9th European software engineering conference held jointly with 11th ACM SIGSOFT international symposium on Foundations of software engineering
            September 2003
            394 pages
            ISBN:1581137435
            DOI:10.1145/940071
            • cover image ACM SIGSOFT Software Engineering Notes
              ACM SIGSOFT Software Engineering Notes  Volume 28, Issue 5
              September 2003
              382 pages
              ISSN:0163-5948
              DOI:10.1145/949952
              Issue’s Table of Contents

            Copyright © 2003 ACM

            Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 1 September 2003

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • Article

            Acceptance Rates

            ESEC/FSE-11 Paper Acceptance Rate33of168submissions,20%Overall Acceptance Rate112of543submissions,21%

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader