More Secure Vue & Nuxt Apps - By Default

Rate this content
Bookmark

As developers we usually have to develop fast and because of that some Software Quality aspects such as Performance, Accessibility or Security can suffer. Configuring web applications to be protected against common threats and hackers is difficult. And that is why, you can use Nuxt Security -> a module for Nuxt that will help you build more secure applications without additional configuration needed! 

In this talk, I will guide you through the concepts of Security in modern web applications and OWASP to help you build more secure Vue & Nuxt applications!

This talk has been presented at Vue.js Live 2024, check out the latest edition of this Tech Conference.

FAQ

Front-end developers should be aware of security risks and issues that can appear in modern web applications, especially as more functionality is being forwarded to the front-end.

OWASP (Open Web Application Security Project) is a standard awareness document for both developers and web application security specialists, representing a broad consensus about the most critical security risks to web applications. It is recognized as a first step towards more secure coding.

The main types of injection attacks are cross-site scripting (XSS) and SQL injections. These attacks involve injecting malicious code into an application, either through SQL databases or JavaScript, to gain unauthorized access to data.

Broken access control occurs when an attacker can access data or resources that they should not be able to, typically due to improper authorization checks in the application.

A denial of service (DOS) attack occurs when an attacker sends too many requests to a server, overwhelming it and preventing it from serving legitimate users. A distributed denial of service (DDOS) attack involves multiple devices participating in the attack.

Malicious NPM packages and dependency confusion occur when a user unintentionally fetches a package with the same name from a public registry instead of a private one, potentially introducing malicious code into the application.

HTTP security headers are sent from the server to inform the browser about security policies, such as only allowing HTTPS, restricting the use of certain APIs like geolocation or camera, and defining which domains can be accessed for resources.

The Nuxt Security module is a tool that configures your Nuxt applications to follow OWASP security patterns and recommendations by default. It includes features like security response headers, cross-site scripting validation, and rate limiters.

Static applications can benefit from the Nuxt Security module through features like content security policy meta tags and utilities to remove console loggers, ensuring that these applications maintain a level of security even without a server.

Yes, you can use tools like securityheaders.com to audit your website for security headers and ensure they pass recommended values. Other security header scanners are also available online.

Jakub Andrzejewski
Jakub Andrzejewski
21 min
25 Apr, 2024

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Handling security in front-end development is crucial, and the OWASP Top 10 is a valuable resource for secure coding. The list of security risks is constantly evolving, and the Nuxt security module provides features like security headers, rate limiting, and cross-site request forgery protection. Frontend developers should prioritize security to avoid information leaks and mitigate risks. Understanding the difference between public and private tokens is important for secure token handling.

1. Introduction to Secure Next Apps

Short description:

Handling security is traditionally seen as the responsibility of back-end developers or DevOps engineers. However, with more functionality being moved to the front-end, it is important for everyone to prioritize security. In this presentation, I will discuss more secure Next apps by default and raise awareness about security risks in modern web applications. One crucial resource is OWASP Top 10, a document that highlights the most critical security risks. It is recognized as the first step towards more secure coding. The list of security risks is constantly evolving, as seen on the OWASP Top 10 website.

Hi there. I always thought that handling security should be a responsibility of back-end developers or DevOps engineers. But nowadays, more and more functionality is being forwarded to the front-end. And that is why I believe that everyone should be taking care of security. And that is also why I have selected this topic for my today's presentation, which is more secure Next apps by default.

My name is Jakub and I work at Allokai as a senior developer and advocate. Apart from that, I'm also a Google developer expert in web performance. I am part of the Next team and I'm also an ambassador for Algolia, Storyblok, Cloudinary, and SuperBase. So, after this presentation, you will be a security ninja. That sounds great, right? But the reality is that it is not possible. It is not possible to transfer to you all the security knowledge that is necessary to build secure applications out of the box. So, my idea is to make you more aware of security risks and issues that can appear in modern web applications. Because I believe that if you are aware of these issues, you will be able to protect your application against them.

So, for that, I would recommend you to become familiar with the concept of OWASP and specifically OWASP Top 10. So, OWASP is a standard awareness document for both developers and web security, web application security specialists, and it represents broad consensus about the most critical security risks to web applications. And as you can see, I marked two places here. One is standard awareness document, which basically means that this OWASP Top 10 is a document. And the second one, security risks. So, it is a document that will showcase to you the most popular security risks. OWASP Top 10 is also recognized by developers as the first step towards more secure coding. This time as well, marked with green color, first step.

So, if you look at the OWASP Top 10 website, you will see basically this. And if we zoom in a bit, we will see this list of most popular security risks that can appear in your web application. And as you can see on the left side, we have 2017, and on the right side, there's 2021. And you see that the list, both the order and the elements of the list are changing. Which means that this list is evolving over and over. Like all the time.

2. Overview of Security Risks

Short description:

The list of security risks is constantly evolving, as new issues and risks emerge. OWASP's website provides a wealth of knowledge, including checklists and cheat sheets for different application types. We'll focus on a few selected risks, such as cross-site scripting and SQL injections. Broken access control can allow unauthorized access to sensitive data. DOS and DDOS attacks can overwhelm an application's server, causing it to become unresponsive. Additionally, malicious NPM packages and dependency confusion pose a significant threat to web applications.

And you see that the list, both the order and the elements of the list are changing. Which means that this list is evolving over and over. Like all the time. Because new issues or new risks are appearing and we have to make our apps more and more secure based on changing environments.

And there is also a big, very big resource of knowledge in terms of making your app more secure on OWASP's website, which is basically a list of checklists, like cheat sheets, that you can review to see if your application is secure in a certain area. So, for example, we have cheat sheet for REST applications, GraphQL applications, applications built with Ruby and so on and so on.

So, let's take a look at some of these security risks. We won't be taking a look at all of them, we'll be focusing only on a few selected ones. So, first of all, we have injections. And the two main attacks here, or risks, are cross-site scripting and SQL injections. And in terms of SQL injections, you might think that this is a very old vulnerability and it doesn't appear anymore, but you would be surprised how many production websites have this kind of vulnerability still.

In both cases, the idea is that the attacker is injecting some kind of malicious code in either SQL, so our database, or in the applications through JavaScript, for example, and then this malicious code is basically getting the data getting the shouldn't have access to, like users, passwords, stuff like that. Going further, we have broken access control. Access control means that our application will allow to get certain data if we are properly authorized.

So, for example, we are logged in, or we are part of organization, or group, that has access to certain resource. So, broken access control means that the attacker can have access to the data that basically he or she shouldn't have. And my favorite one, which is DOS, or DDOS, which means denial of service, means that our application is served on a server that can serve or handle only a certain amount of requests. So, if attacker manages to send too many requests, our application won't be able to serve the responses to these requests and basically give up.

So, we have DOS, which is denial of service, and DDOS, which is like the distributed denial of service, which is the routing is basically distributed between many different so-called zombie devices. It can be mobile phones, it can be desktop devices, and so on and so on. And I have one interesting bonus case, which is called malicious NPM packages and dependency confusion. This can happen for anyone who is building web applications nowadays.

So, how it works is basically we have a user that is supposed to fetch a package that is stored in a private registry. Like private NPM registry. It could be something else. The idea is that this registry is like a private one, and only authorized users should have access to it, should be able to fetch this package. So, what the user does instead unintentionally is to fetch the package with the same name, but from the public registry, like the public NPM. And this package can contain a malicious code. And this is a real case. And this is, unfortunately, this is in Polish.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

A Guide to React Rendering Behavior
React Advanced Conference 2022React Advanced Conference 2022
25 min
A Guide to React Rendering Behavior
Top Content
This transcription provides a brief guide to React rendering behavior. It explains the process of rendering, comparing new and old elements, and the importance of pure rendering without side effects. It also covers topics such as batching and double rendering, optimizing rendering and using context and Redux in React. Overall, it offers valuable insights for developers looking to understand and optimize React rendering.
Speeding Up Your React App With Less JavaScript
React Summit 2023React Summit 2023
32 min
Speeding Up Your React App With Less JavaScript
Top Content
Watch video: Speeding Up Your React App With Less JavaScript
Mishko, the creator of Angular and AngularJS, discusses the challenges of website performance and JavaScript hydration. He explains the differences between client-side and server-side rendering and introduces Quik as a solution for efficient component hydration. Mishko demonstrates examples of state management and intercommunication using Quik. He highlights the performance benefits of using Quik with React and emphasizes the importance of reducing JavaScript size for better performance. Finally, he mentions the use of QUIC in both MPA and SPA applications for improved startup performance.
React Concurrency, Explained
React Summit 2023React Summit 2023
23 min
React Concurrency, Explained
Top Content
Watch video: React Concurrency, Explained
React 18's concurrent rendering, specifically the useTransition hook, optimizes app performance by allowing non-urgent updates to be processed without freezing the UI. However, there are drawbacks such as longer processing time for non-urgent updates and increased CPU usage. The useTransition hook works similarly to throttling or bouncing, making it useful for addressing performance issues caused by multiple small components. Libraries like React Query may require the use of alternative APIs to handle urgent and non-urgent updates effectively.
The Future of Performance Tooling
JSNation 2022JSNation 2022
21 min
The Future of Performance Tooling
Top Content
Today's Talk discusses the future of performance tooling, focusing on user-centric, actionable, and contextual approaches. The introduction highlights Adi Osmani's expertise in performance tools and his passion for DevTools features. The Talk explores the integration of user flows into DevTools and Lighthouse, enabling performance measurement and optimization. It also showcases the import/export feature for user flows and the collaboration potential with Lighthouse. The Talk further delves into the use of flows with other tools like web page test and Cypress, offering cross-browser testing capabilities. The actionable aspect emphasizes the importance of metrics like Interaction to Next Paint and Total Blocking Time, as well as the improvements in Lighthouse and performance debugging tools. Lastly, the Talk emphasizes the iterative nature of performance improvement and the user-centric, actionable, and contextual future of performance tooling.
Optimizing HTML5 Games: 10 Years of Learnings
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Optimizing HTML5 Games: 10 Years of Learnings
Top Content
PlayCanvas is an open-source game engine used by game developers worldwide. Optimization is crucial for HTML5 games, focusing on load times and frame rate. Texture and mesh optimization can significantly reduce download sizes. GLTF and GLB formats offer smaller file sizes and faster parsing times. Compressing game resources and using efficient file formats can improve load times. Framerate optimization and resolution scaling are important for better performance. Managing draw calls and using batching techniques can optimize performance. Browser DevTools, such as Chrome and Firefox, are useful for debugging and profiling. Detecting device performance and optimizing based on specific devices can improve game performance. Apple is making progress with WebGPU implementation. HTML5 games can be shipped to the App Store using Cordova.
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Top Content
The talk discusses the importance of supply chain security in the open source ecosystem, highlighting the risks of relying on open source code without proper code review. It explores the trend of supply chain attacks and the need for a new approach to detect and block malicious dependencies. The talk also introduces Socket, a tool that assesses the security of packages and provides automation and analysis to protect against malware and supply chain attacks. It emphasizes the need to prioritize security in software development and offers insights into potential solutions such as realms and Deno's command line flags.

Workshops on related topic

React Performance Debugging Masterclass
React Summit 2023React Summit 2023
170 min
React Performance Debugging Masterclass
Top Content
Featured WorkshopFree
Ivan Akulov
Ivan Akulov
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
Building WebApps That Light Up the Internet with QwikCity
JSNation 2023JSNation 2023
170 min
Building WebApps That Light Up the Internet with QwikCity
Featured WorkshopFree
Miško Hevery
Miško Hevery
Building instant-on web applications at scale have been elusive. Real-world sites need tracking, analytics, and complex user interfaces and interactions. We always start with the best intentions but end up with a less-than-ideal site.
QwikCity is a new meta-framework that allows you to build large-scale applications with constant startup-up performance. We will look at how to build a QwikCity application and what makes it unique. The workshop will show you how to set up a QwikCitp project. How routing works with layout. The demo application will fetch data and present it to the user in an editable form. And finally, how one can use authentication. All of the basic parts for any large-scale applications.
Along the way, we will also look at what makes Qwik unique, and how resumability enables constant startup performance no matter the application complexity.
Next.js 13: Data Fetching Strategies
React Day Berlin 2022React Day Berlin 2022
53 min
Next.js 13: Data Fetching Strategies
Top Content
WorkshopFree
Alice De Mauro
Alice De Mauro
- Introduction- Prerequisites for the workshop- Fetching strategies: fundamentals- Fetching strategies – hands-on: fetch API, cache (static VS dynamic), revalidate, suspense (parallel data fetching)- Test your build and serve it on Vercel- Future: Server components VS Client components- Workshop easter egg (unrelated to the topic, calling out accessibility)- Wrapping up
0 to Auth in an hour with ReactJS
React Summit 2023React Summit 2023
56 min
0 to Auth in an hour with ReactJS
WorkshopFree
Kevin Gao
Kevin Gao
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool. There are multiple alternatives that are much better than passwords to identify and authenticate your users - including SSO, SAML, OAuth, Magic Links, One-Time Passwords, and Authenticator Apps.
While addressing security aspects and avoiding common pitfalls, we will enhance a full-stack JS application (Node.js backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session securely for subsequent client requests, validating / refreshing sessions- Basic Authorization - extracting and validating claims from the session token JWT and handling authorization in backend flows
At the end of the workshop, we will also touch other approaches of authentication implementation with Descope - using frontend or backend SDKs.
React Performance Debugging
React Advanced Conference 2023React Advanced Conference 2023
148 min
React Performance Debugging
Workshop
Ivan Akulov
Ivan Akulov
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
Web Accessibility for Ninjas: A Practical Approach for Creating Accessible Web Applications
React Summit 2023React Summit 2023
109 min
Web Accessibility for Ninjas: A Practical Approach for Creating Accessible Web Applications
Workshop
Asaf Shochet Avida
Eitan Noy
2 authors
In this hands-on workshop, we’ll equip you with the tools and techniques you need to create accessible web applications. We’ll explore the principles of inclusive design and learn how to test our websites using assistive technology to ensure that they work for everyone.
We’ll cover topics such as semantic markup, ARIA roles, accessible forms, and navigation, and then dive into coding exercises where you’ll get to apply what you’ve learned. We’ll use automated testing tools to validate our work and ensure that we meet accessibility standards.
By the end of this workshop, you’ll be equipped with the knowledge and skills to create accessible websites that work for everyone, and you’ll have hands-on experience using the latest techniques and tools for inclusive design and testing. Join us for this awesome coding workshop and become a ninja in web accessibility and inclusive design!