Skip to content

Commit f09d61f

Browse files
If unsanitized user input is written to a log entry, a malicious user may be able to forge new log entries.
1 parent 74d4acb commit f09d61f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app/quickapi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ async def create_item(item: UserColorEntry):
4040
"""Create an item with a username and users favourite colour and return it."""
4141
user_colour.append(item)
4242
print(user_colour)
43-
logger.info(item)
43+
# Sanitize log message to prevent log injection
44+
logger.info("New user-color entry added: username=%s, color=%s", item.username, item.color)
4445
return item
4546

4647
# List all user_colour mappings

0 commit comments

Comments
 (0)