During development and finishing up the security implementation I tried to keep the OWASP top 10 in mind. The current implementation does not meet all of the OWASP requirements. I have described for each topic what I tried to do to meet the OWASP requirement or what has to be done to fulfill that requirement.
1. Injection. Injection flaws, such as SQL, NoSQL, OS, and LDAP injection, occur when untrusted data is sent to an interpreter as part of a command or query. The attacker’s hostile data can trick the interpreter into executing unintended commands or accessing data without proper authorization.
As far as I know SQL injection can not be used on my implementation due to the way how JpaRepositories work. All data that gets saved to the database gets saved through the .save function on these JpaRepostories. From what I can find online the .save function is protected against SQL injection.
This kind of JpaRepository implementation as shown here should also be safe against SQL injection.
2. Broken Authentication. Application functions related to authentication and session management are often implemented incorrectly, allowing attackers to compromise passwords, keys, or session tokens, or to exploit other implementation flaws to assume other users’ identities temporarily or permanently.
The current implementation does not fully meet all the requirements to resolve this vulnerability. The things that need to be fixed to be protected from this kind of vulnerability are the following:
3. Sensitive Data Exposure. Many web applications and APIs do not properly protect sensitive data, such as financial, healthcare, and PII. Attackers may steal or modify such weakly protected data to conduct credit card fraud, identity theft, or other crimes. Sensitive data may be compromised without extra protection, such as encryption at rest or in transit, and requires special precautions when exchanged with the browser.
The current implementation does not story any sensitive user data and it doesn't need any to function. The only sensitive data would be passwords, but passwords are only entered on login and never sent back to clients.
4. XML External Entities (XXE). Many older or poorly configured XML processors evaluate external entity references within XML documents. External entities can be used to disclose internal files using the file URI handler, internal file shares, internal port scanning, remote code execution, and denial of service attacks.
My application does not feature a webpage as frontend and uses unity instead. Furthermore I do not use XML in my application.
5. Broken Access Control. Restrictions on what authenticated users are allowed to do are often not properly enforced. Attackers can exploit these flaws to access unauthorized functionality and/or data, such as access other users’ accounts, view sensitive files, modify other users’ data, change access rights, etc.
I do not think my implementation is vulnerable to these type of attacks. When a client makes a REST call or attempts to establish a websocket connection, a token has to be sent in a header with that call. This token is only received by the client on a successful login. Every rest call other than sing-up or login requires a token to be present otherwise it will return a 401 unauthorized HTML error. Parameters can also not be edited in URLs as I don't use them, almost all data is retrieved from the body included with REST calls.
6. Security Misconfiguration. Security misconfiguration is the most commonly seen issue. This is commonly a result of insecure default configurations, incomplete or ad hoc configurations, open cloud storage, misconfigured HTTP headers, and verbose error messages containing sensitive information. Not only must all operating systems, frameworks, libraries, and applications be securely configured, but they must be patched/upgraded in a timely fashion.
Error messages user clients may receive never include any information other than the error type. If something goes wrong in the implementation of a service it will result in a 500 error. Unauthorized requests will return a 401.
7. Cross-Site Scripting XSS. XSS flaws occur whenever an application includes untrusted data in a new web page without proper validation or escaping, or updates an existing web page with user-supplied data using a browser API that can create HTML or JavaScript. XSS allows attackers to execute scripts in the victim’s browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites.
The user client is a unity instance which does not allow for javascript injection. If you would want to execute XSS attacks I think you would have to modify the unity games compiled code which is not as easy as editing HTML code/scripts.
8. Insecure Deserialization. Insecure deserialization often leads to remote code execution. Even if deserialization flaws do not result in remote code execution, they can be used to perform attacks, including replay attacks, injection attacks, and privilege escalation attacks.
My current implementation is not fully protected against this vulnerability. All communication between the services and the client is done with JSON. The client and services always deserialize to a specific class. For an example, let's say a user wants to send an auction request with a modified JSON object. The user has modified the JSON object to tell the auction service to sell an item the user does not own. The check will first go through the inventory service and check for validity. If the player does not own the item that the modified JSON is pointing to the auction will not be created. If the player however does own that item then it will still create an auction with that other item. This does no harm however as the correct item will still be taken from their inventory.
To better protect against tampered objects, some form of logging could be implemented. This would log deserialization exceptions and failures when an incoming type is not the expected type as well as network activity. Integrity checks such as digital signatures on serialized objects could also prevent tampering.
9. Using Components with Known Vulnerabilities. Components, such as libraries, frameworks, and other software modules, run with the same privileges as the application. If a vulnerable component is exploited, such an attack can facilitate serious data loss or server takeover. Applications and APIs using components with known vulnerabilities may undermine application defenses and enable various attacks and impacts.
During development I made sure to not include any dependencies that were not going to be used as well as made sure to keep every library and module up to date.
10. Insufficient Logging & Monitoring. Insufficient logging and monitoring, coupled with missing or ineffective integration with incident response, allows attackers to further attack systems, maintain persistence, pivot to more systems, and tamper, extract, or destroy data. Most breach studies show time to detect a breach is over 200 days, typically detected by external parties rather than internal processes or monitoring.
Currently the implementation does not log much at all. This is not an oversight, I simply didn't have enough time to properly implement a logging service. This logging service would log all activity across all services and mark suspicious user activity. When suspicious activity is detected it should be responded to in a timely manner.