Remove outdated trusted keys mechanism

This commit is contained in:
Daniel Lugo 2021-12-27 16:21:43 -04:00
parent 12cacca5c3
commit 6484182489
3 changed files with 3 additions and 32 deletions

View file

@ -8,8 +8,6 @@ MS_TO_TOKEN_EXPIRATION=4500000
SHOCK_ENCRYPTION_ECC=true SHOCK_ENCRYPTION_ECC=true
CACHE_HEADERS_MANDATORY=true CACHE_HEADERS_MANDATORY=true
SHOCK_CACHE=true SHOCK_CACHE=true
# Use only if disabling LND encrypt phrase (security risk)
TRUSTED_KEYS=true
# SSH Tunnel Provider # SSH Tunnel Provider
LOCAL_TUNNEL_SERVER=https://tunnel.rip LOCAL_TUNNEL_SERVER=https://tunnel.rip
# Default content to your own seed server # Default content to your own seed server

View file

@ -13,5 +13,4 @@ services:
- 9835:9835 - 9835:9835
volumes: volumes:
- C:\Users\boufn\.polar\networks\2\volumes\lnd\alice:/root/.lnd - C:\Users\boufn\.polar\networks\2\volumes\lnd\alice:/root/.lnd
environment:
TRUSTED_KEYS: 'false'

View file

@ -604,12 +604,9 @@ module.exports = async (
const walletInitialized = await walletExists() const walletInitialized = await walletExists()
const { alias, password } = req.body const { alias, password } = req.body
const lndUp = health.LNDStatus.success const lndUp = health.LNDStatus.success
const trustedKeysEnabled =
process.env.TRUSTED_KEYS === 'true' || !process.env.TRUSTED_KEYS
const walletUnlocked = health.LNDStatus.walletStatus === 'unlocked' const walletUnlocked = health.LNDStatus.walletStatus === 'unlocked'
const { authorization = '' } = req.headers const { authorization = '' } = req.headers
const allowUnlockedLND = process.env.ALLOW_UNLOCKED_LND === 'true' const allowUnlockedLND = process.env.ALLOW_UNLOCKED_LND === 'true'
const trustedKeys = await Storage.get('trustedPKs')
const { lightning } = LightningServices.services const { lightning } = LightningServices.services
if (!lndUp) { if (!lndUp) {
@ -632,30 +629,17 @@ module.exports = async (
throw new Error('Invalid alias/password combination') throw new Error('Invalid alias/password combination')
} }
const [isKeyTrusted = !trustedKeysEnabled] = (trustedKeys || []).filter(
trustedKey => trustedKey === publicKey
)
if (!isKeyTrusted) {
logger.warn('Untrusted public key!')
}
if (!walletUnlocked) { if (!walletUnlocked) {
await unlockWallet(password) await unlockWallet(password)
} }
if ( if (walletUnlocked && !authorization && !allowUnlockedLND) {
walletUnlocked &&
!authorization &&
!isKeyTrusted &&
!allowUnlockedLND
) {
throw new Error( throw new Error(
'Invalid alias/password combination (Untrusted Device)' 'Invalid alias/password combination (Untrusted Device)'
) )
} }
if (walletUnlocked && !isKeyTrusted && !allowUnlockedLND) { if (walletUnlocked && !allowUnlockedLND) {
const validatedToken = await validateToken( const validatedToken = await validateToken(
authorization.replace('Bearer ', '') authorization.replace('Bearer ', '')
) )
@ -667,10 +651,6 @@ module.exports = async (
} }
} }
if (!isKeyTrusted) {
await Storage.set('trustedPKs', [...(trustedKeys || []), publicKey])
}
// Generate auth token and send it as a JSON response // Generate auth token and send it as a JSON response
const token = await auth.generateToken() const token = await auth.generateToken()
@ -796,9 +776,6 @@ module.exports = async (
GunDB.mySEA GunDB.mySEA
) )
const trustedKeys = await Storage.get('trustedPKs')
await Storage.setItem('trustedPKs', [...(trustedKeys || []), publicKey])
const [initWalletErr, initWalletResponse] = await new Promise(res => { const [initWalletErr, initWalletResponse] = await new Promise(res => {
walletUnlocker.initWallet( walletUnlocker.initWallet(
walletArgs, walletArgs,
@ -873,7 +850,6 @@ module.exports = async (
app.post('/api/lnd/wallet/existing', async (req, res) => { app.post('/api/lnd/wallet/existing', async (req, res) => {
try { try {
const trustedKeys = await Storage.get('trustedPKs')
const { password, alias } = req.body const { password, alias } = req.body
const healthResponse = await checkHealth() const healthResponse = await checkHealth()
const exists = await walletExists() const exists = await walletExists()
@ -923,8 +899,6 @@ module.exports = async (
// Register user after verifying wallet password // Register user after verifying wallet password
const publicKey = await GunDB.register(alias, password) const publicKey = await GunDB.register(alias, password)
await Storage.setItem('trustedPKs', [...(trustedKeys || []), publicKey])
// Generate Access Token // Generate Access Token
const token = await auth.generateToken() const token = await auth.generateToken()
setTimeout(() => { setTimeout(() => {