diff --git a/cmd/age/parse.go b/cmd/age/parse.go index b12a486..71d1c5b 100644 --- a/cmd/age/parse.go +++ b/cmd/age/parse.go @@ -91,6 +91,9 @@ func parseRecipientsFile(name string) ([]age.Recipient, error) { warningf("recipients file %q: ignoring unsupported SSH key of type %q at line %d", name, t, n) continue } + if strings.HasPrefix(line, "AGE-") { + return nil, fmt.Errorf("%q: error at line %d: apparent identity found in recipients file", name, n) + } // Hide the error since it might unintentionally leak the contents // of confidential files. return nil, fmt.Errorf("%q: malformed recipient at line %d", name, n) @@ -235,6 +238,9 @@ func parseIdentities(f io.Reader) ([]age.Identity, error) { } i, err := parseIdentity(line) if err != nil { + if strings.HasPrefix(line, "age1") { + return nil, fmt.Errorf("error at line %d: apparent recipient found in identities file", n) + } return nil, fmt.Errorf("error at line %d: %v", n, err) } ids = append(ids, i) diff --git a/parse.go b/parse.go index f808fc6..99c15d4 100644 --- a/parse.go +++ b/parse.go @@ -87,9 +87,7 @@ func ParseRecipients(f io.Reader) ([]Recipient, error) { } r, err := parseRecipient(line) if err != nil { - // Hide the error since it might unintentionally leak the contents - // of confidential files. - return nil, fmt.Errorf("malformed recipient at line %d", n) + return nil, fmt.Errorf("error at line %d: %v", n, err) } recs = append(recs, r) }