Security Audit Finding
Severity: Medium
File: node/beacon_api.py:680-720 (chat endpoint)
Issue: The /api/chat endpoint stores user messages directly in the database and returns them without any HTML/script sanitization. An attacker can inject <script> tags or event handlers that execute when other users view the chat history.
Code:
@beacon_api.route('/api/chat', methods=['POST'])
def chat():
data = request.get_json()
message = data.get('message') # No sanitization!
db.execute(
"INSERT INTO beacon_chat ... VALUES (?, 'user', ?, ...)",
(agent_id, message, ...) # Stored raw
)
Impact:
- Attacker can inject JavaScript that executes in other users' browsers
- Session hijacking, credential theft, or phishing via injected content
- The chat history endpoint returns raw stored content
Fix:
- Sanitize input: strip HTML tags or escape special characters
- Use Content-Security-Policy headers
- Return responses with
Content-Type: application/json (already done, but ensure no HTML rendering)
Wallet: RTC4642c5ee8467f61ed91b5775b0eeba984dd776ba
Security Audit Finding
Severity: Medium
File: node/beacon_api.py:680-720 (chat endpoint)
Issue: The
/api/chatendpoint stores user messages directly in the database and returns them without any HTML/script sanitization. An attacker can inject<script>tags or event handlers that execute when other users view the chat history.Code:
Impact:
Fix:
Content-Type: application/json(already done, but ensure no HTML rendering)Wallet: RTC4642c5ee8467f61ed91b5775b0eeba984dd776ba