balena-io-examples / balena-aws-lambda Goto Github PK
View Code? Open in Web Editor NEWAssociate balena devices with AWS IoT when they ping a lambda endpoint
Associate balena devices with AWS IoT when they ping a lambda endpoint
We are a security research team and we recently discovered that there is an over-authorization security issue with this project's IoT policy.
The affected file is as following:
1. balena-aws-lambda/policy.json
I was unable to run the project locally due to outdated dependencies and usage. I have not yet tried to run on AWS as a Lambda function. I was able to work around these issues to the point that I could create a thing with its certificates and policies, as well as generate the environment variables in balenaCloud. Below are the problems I encountered.
Use of resin-sdk
resin-sdk has been replaced with balena-sdk. Updated package.json
and use in resin-integrator/index.js
. Also in that file, updated how environment variables are set to use resin.models.device.envVar.set()
Use of promisifyAll()
Both resin-integrator/index.js
and resin-aws/index.js
use Promise.promisifyAll()
. However, promisifyAll() fails because the libraries to update already include functions that end with "Async"
. I used a different suffix to work around the problem, but there may be a better way.
Other issues
.env
When I run node-lambda run
, I get:
Error: ResinDeviceNotFound: Device not found: ################
The #'s are a long ID that I don't recognize.
When a device attempts to provision via the server side code, the server code first uses the balena API to validate that the device UUID is valid. The first step in validation is to login to the user's account with their email address and password. However if 2FA is enabled, this attempt fails with an error like,
Error: BalenaRequestError: Request error: Unauthorized
The solution is to login here with an API key token, via the sdk auth.loginWithToken()
function.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.