Navigating Early Career Hurdles: Security (Keeping User Data Safe as a Frontend Engineer)

RMAG news

In software product development, security is one foundational principle on which your product relies heavily. Put, security encompasses all practices aimed at safeguarding digital solutions from attackers, ensuring unauthorized access to systems and data is prevented. With this understanding in mind, it becomes a shared responsibility for every engineer to prioritize. While security comprises various components, this post will focus on addressing one of these integral parts.

Challenge

In the early stages of my software engineering journey, I encountered a notable obstacle: securely storing essential user data within the browser, while also ensuring it remained encrypted and inaccessible to unauthorized individuals. This challenge proved to be a frequent hurdle as I navigated the beginnings of my career. Unfortunately, many of the resources available to me at the time overlooked the critical nature of this issue. Consequently, I found myself inadvertently storing and inadvertently exposing sensitive user data within the browser environment.

Primarily, there are three common methods for storing data in a browser:

Cookies: These are small pieces of data stored as key-value pairs. Cookies are commonly used to store user-specific information and are sent with every HTTP request to the server.
Local Storage: Offering a larger storage capacity than cookies, local storage does not accompany every HTTP request, thereby improving performance. Data stored in local storage persists even after the browser is closed, remaining on the user’s device as key-value pairs.
Session Storage: Similar to local storage, session storage also stores data as key-value pairs. However, it is limited by the system memory and only lasts for the duration of the user’s session. Data stored in session storage is available until the browser is closed.

While each of these methods continues to serve its purpose across different scenarios, a crucial aspect often goes unnoticed: the accessibility of stored data during the lifespan of these storage methods. This oversight directly conflicts with one of the fundamental principles of the CIA Triad: Confidentiality. Depending on the sensitivity of the data, exposing it to potential threats poses substantial risks. Thus, it becomes imperative to devise a solution that guarantees the full security and confidentiality of this data.

Solution:

After thorough consideration of the issue and collaborating with a well-structured team comprising seasoned engineers, I discovered a viable solution: ENCRYPTION.

Encryption is a process of encoding information in such a way that only authorized parties can access it. It involves converting plaintext (readable data) into ciphertext (encoded data) using an encryption algorithm and a cryptographic key. The encrypted data can only be decoded back into plaintext by someone possessing the corresponding decryption key.

The fundamental aim of encryption lies in safeguarding sensitive data by upholding both its confidentiality and integrity, By encrypting data, it becomes unintelligible to unauthorized users or attackers who may attempt to intercept or access it unlawfully. Encryption serves as a powerful tool for protecting data privacy, preventing unauthorized access, and securing communication channels.

Implementation:

Implementing the solution involved integrating encryption techniques into the application’s data storage mechanism. I encrypted the user data before storing it in the browser’s sessionStorage or localStorage.

The implementation process begins with a thorough assessment of the encryption methods available, ranging from symmetric and asymmetric encryption to hashing algorithms and tokenization techniques. Each method comes with its own set of strengths and weaknesses, which must be weighed against the requirements of the application.

Once a suitable method has been selected, it is essential to ensure proper integration within the frontend architecture. This may involve leveraging built-in encryption libraries, implementing custom solutions, or integrating with third-party services for enhanced security features.

For most of my apps, I tend to gravitate towards using AES (Advanced Encryption Standard) encryption as my preferred method for several reasons:

Security Strength: AES is widely acknowledged as a highly secure encryption algorithm, having undergone rigorous testing and scrutiny by cryptographers.
Performance: AES is optimized for efficient execution across a wide array of hardware and software platforms. Its fast encryption and decryption speeds make it ideal for front-end applications where responsiveness is paramount.
Versatility: AES offers support for various key lengths, ranging from 128-bit to 256-bit. This flexibility enables developers to tailor the level of security to meet specific requirements, striking a balance between security and performance.
Ease of Implementation: AES encryption is well-supported in popular programming languages and libraries commonly used in frontend engineering. Additionally, there are third-party libraries available that simplify the setup and utilization of AES encryption, further streamlining the implementation process

Outcome:

The implementation of encryption proved highly effective. Users’ sensitive information remained shielded from prying eyes, even in the event of unauthorized access to the browser’s storage. This not only bolstered the security of the application but also instilled confidence in users regarding the protection of their data.

Conclusion:

Navigating the challenges of early career endeavors in data security underscored the importance of proactive measures and innovative solutions. By leveraging different encryption algorithms, I not only addressed a pressing issue but also gained valuable insights into the intricacies of safeguarding user data. This experience led me to understand security as a core component of software systems, emphasizing the critical role of security in building trust and reliability in digital systems.

Leave a Reply

Your email address will not be published. Required fields are marked *