Skip to content

security: replace pickle with json for cookie storage#4

Merged
mugenkyou merged 1 commit intomugenkyou:mainfrom
asmiverma:main
Mar 16, 2026
Merged

security: replace pickle with json for cookie storage#4
mugenkyou merged 1 commit intomugenkyou:mainfrom
asmiverma:main

Conversation

@asmiverma
Copy link
Contributor

Pull Request Summary

Security: Replace unsafe pickle-based cookie serialization with JSON to eliminate a potential remote code execution (RCE) vulnerability.

This update addresses an insecure deserialization issue found in app.py (lines 122 and 334) where cookie data was loaded using pickle.load(). Since pickle can execute arbitrary code during deserialization, it poses a security risk if the file is tampered with.

This PR replaces pickle-based storage with JSON, a safe serialization format that cannot execute code.

Fixes #1


Changes Introduced

  • Replace pickle.load() / pickle.dump() with json.load() / json.dump() in app.py and related scripts
  • Change cookie storage file extension from .pkl to .json
  • Update file open modes from binary (rb, wb) to text mode (r, w)
  • Ensure cookie dictionaries are properly serialized to JSON

Security Impact

Using Python's pickle module for loading stored cookies can allow arbitrary code execution if the serialized file is modified or replaced by a malicious actor.

Switching to JSON removes this risk because JSON only stores data and cannot execute code during deserialization.

This change mitigates the OWASP insecure deserialization vulnerability.


Screenshots / Demo

N/A — backend security improvement with no UI changes.

Before After
N/A N/A

Checklist

  • Code follows project conventions and best practices
  • Security risk removed (unsafe pickle deserialization)
  • No functional regression in cookie handling
  • Documentation updated where applicable
  • No UI impact

Additional Notes

  • Selenium's driver.get_cookies() returns dictionaries, which are fully compatible with JSON serialization.
  • Any previously saved .pkl cookie files will need to be removed so the application can generate new .json cookie files on the next login.

- Replace pickle.load/dump with json.load/dump in app.py and scripts
- Change cookie file extension from .pkl to .json
- Eliminates arbitrary code execution (RCE) risk from pickle deserialization
- Addresses OWASP insecure deserialization vulnerability
@github-actions
Copy link

📥 Pull Request Received

Thank you for your contribution to Linkify. Your pull request has been received and is currently under review.

🔗 Linked Issues

✅ Pre-Merge Checklist

Please ensure the following requirements are met:

  • Changes adhere to contribution guidelines
  • Related issues are referenced in description
  • All changes tested and verified locally
  • Code follows project standards

👤 Reviewer Assigned

@mugenkyou has been assigned to review this pull request.


Our team will review your submission shortly. We appreciate your effort in improving Linkify.

@mugenkyou mugenkyou merged commit 5e6443a into mugenkyou:main Mar 16, 2026
1 check passed
@github-actions
Copy link

🎉 Pull Request Merged Successfully

Contributor: @asmiverma

Your pull request has been successfully merged into the main codebase. Thank you for your valuable contribution to Linkify.

🚀 Next Steps

We encourage you to:

  • ⭐ Star the repository to support the project
  • 👀 Watch for updates and participate in discussions
  • 🔄 Continue contributing to enhance the platform

We value your commitment to improving Linkify and look forward to your continued involvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants